Skip to content

Nightly Rust hangs forever with a simple 2-line dotenv_codegen and println! #62167

Closed

Description

@brainstorm

The offending code is just a dotenv macro inside a println! macro:

fn main() {
    println!("{}", dotenv!("AWS_ATHENA_DB").to_string());
    println!(dotenv!("AWS_ATHENA_DB").to_string());
}

Just clone the following repository and run cargo build:

https://github.com/brainstorm/dotenv-codegen-rustc-hang

Stays on Building forever:

$ cargo build --verbose
       Fresh unicode-xid v0.1.0
       Fresh cc v1.0.37
       Fresh rustc-demangle v0.1.15
       Fresh lazy_static v1.3.0
       Fresh ucd-util v0.1.3
       Fresh cfg-if v0.1.9
       Fresh utf8-ranges v1.0.3
       Fresh proc-macro2 v0.4.30
       Fresh thread_local v0.3.6
       Fresh regex-syntax v0.6.7
       Fresh quote v0.6.12
       Fresh libc v0.2.58
       Fresh memchr v2.2.0
       Fresh syn v0.15.38
       Fresh backtrace-sys v0.1.29
       Fresh aho-corasick v0.7.3
       Fresh synstructure v0.10.2
       Fresh backtrace v0.3.32
       Fresh regex v1.1.7
       Fresh proc-macro-hack v0.5.7
       Fresh failure_derive v0.1.5
       Fresh failure v0.1.5
       Fresh dotenv v0.14.1
       Fresh dotenv_codegen_implementation v0.14.1
       Fresh dotenv_codegen v0.14.1
   Compiling dotenv-codegen-rustc-hang v0.1.0 (/home/limsadmin/.rvalls/dotenv-codegen-rustc-hang)
     Running `rustc --edition=2018 --crate-name dotenv_codegen_rustc_hang src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=8547a0ee33801234 -C extra-filename=-8547a0ee33801234 --out-dir /home/limsadmin/.rvalls/dotenv-codegen-rustc-hang/target/debug/deps -C incremental=/home/limsadmin/.rvalls/dotenv-codegen-rustc-hang/target/debug/incremental -L dependency=/home/limsadmin/.rvalls/dotenv-codegen-rustc-hang/target/debug/deps --extern dotenv_codegen=/home/limsadmin/.rvalls/dotenv-codegen-rustc-hang/target/debug/deps/libdotenv_codegen-f886d4c0e76d6020.rlib`
    Building [======================================================>  ] 39/40: dotenv-codegen-rustc-hang(bin)

Meta

rustc 1.37.0-nightly (d3e2cec29 2019-06-26)
binary: rustc
commit-hash: d3e2cec29225a46298ec4ebf082f34ebd7cfeecf
commit-date: 2019-06-26
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0

Activity

  1. added
    C-bugCategory: This is a bug.
    I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 27, 2019
  2. added
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    and removed
    C-bugCategory: This is a bug.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 27, 2019
  3. oli-obk commented on Jun 27, 2019

    @oli-obk
    Contributor

    unnominating, I'm guessing it's a dotenv problem and not a rustc problem. The compilation probably hangs forever because the dotenv proc macro blocks or goes into an infinite loop

  4. jonas-schievink commented on Jun 27, 2019

    @jonas-schievink
    Contributor

    What's AWS_ATHENA_DB set to when building?

  5. lukaslueg commented on Jun 27, 2019

    @lukaslueg
    Contributor

    librustc_driver hangs while joining on a thread stuck as

    #0  0x00007f373032266a in scoped_tls::ScopedKey<T>::with () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libsyntax_pos-2ce5298cca1cb4db.so
    #1  0x00007f37303270ef in syntax_pos::<impl syntax_pos::span_encoding::Span>::macro_backtrace () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libsyntax_pos-2ce5298cca1cb4db.so
    #2  0x00007f373055da78 in rustc_errors::emitter::EmitterWriter::fix_multispan_in_std_macros () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_errors-9de40152414e6deb.so
    #3  0x00007f373055a33a in <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_errors-9de40152414e6deb.so
    #4  0x00007f3730573897 in rustc_errors::Handler::emit_db () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_errors-9de40152414e6deb.so
    #5  0x00007f3730556d88 in rustc_errors::diagnostic_builder::DiagnosticBuilder::emit () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_errors-9de40152414e6deb.so
    #6  0x00007f372d64d7e5 in syntax_ext::format::expand_preparsed_format_args () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/../lib/libsyntax_ext-d81e66d3e7998764.so
    #7  0x00007f372d64a4b9 in <F as syntax::ext::base::TTMacroExpander>::expand () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/../lib/libsyntax_ext-d81e66d3e7998764.so
    #8  0x00007f3730b89892 in syntax::ext::expand::MacroExpander::expand_invoc () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libsyntax-301f938611d84d7d.so
    #9  0x00007f3730b8407b in syntax::ext::expand::MacroExpander::expand_fragment () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libsyntax-301f938611d84d7d.so
    #10 0x00007f3730b8326d in syntax::ext::expand::MacroExpander::expand_crate () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libsyntax-301f938611d84d7d.so
    #11 0x00007f373358140b in rustc_interface::passes::configure_and_expand_inner::{{closure}} () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    #12 0x00007f373357877f in rustc::util::common::time () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    #13 0x00007f373352410d in rustc_interface::passes::configure_and_expand_inner () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    #14 0x00007f37335808ef in rustc_interface::passes::configure_and_expand::{{closure}} () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    #15 0x00007f3733550842 in rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    #16 0x00007f3733521276 in rustc_interface::passes::configure_and_expand () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    #17 0x00007f3733511d5e in rustc_interface::queries::Query<T>::compute () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    #18 0x00007f37335125bd in rustc_interface::queries::Query<T>::compute () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    #19 0x00007f37335115a6 in rustc_interface::queries::Query<T>::compute () from /home/lukas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_interface-a6451c13da8356b3.so
    
    
  6. brainstorm commented on Jun 27, 2019

    @brainstorm
    Author
  7. brainstorm commented on Jul 3, 2019

    @brainstorm
    Author

    @oli-obk After poking around it for a few minutes, it seems like https://github.com/dtolnay/proc-macro-hack, a dotenv dependency, is the culprit instead of dotenv-rs/dotenv#22... but in any case, shouldn't rustc's macro processor (plugin?) be more resilient and timeout/fail or handle this more gracefully instead of hanging forever?

  8. dtolnay commented on Jul 3, 2019

    @dtolnay
    Member

    Closing as a duplicate of #44692. @oli-obk -- I believe this is indeed a rustc bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions