Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: Expected module, found DefId #75982

Closed
matthiaskrgr opened this issue Aug 27, 2020 · 7 comments · Fixed by #77984
Closed

ICE: Expected module, found DefId #75982

matthiaskrgr opened this issue Aug 27, 2020 · 7 comments · Fixed by #77984
Assignees
Labels
A-metadata Area: Crate metadata C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Found in the pr-75180 crater run:

git clone https://github.com/getditto/safer_ffi.git
cd safer_ffi
git checkout 661708808922a0dc625a864b0f880d6b8dc4a412
rm -f rust-toolchain
cargo check --all-targets

ICEs:

    Checking safer-ffi v0.0.5 (/tmp/safer_ffi)
thread 'rustc' panicked at 'Expected module, found DefId(20:196)', src/librustc_metadata/rmeta/decoder.rs:1178:13
stack backtrace:
   0:     0x7f8e87a6d380 - std::backtrace_rs::backtrace::libunwind::trace::ha1eabb142084ea37
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
   1:     0x7f8e87a6d380 - std::backtrace_rs::backtrace::trace_unsynchronized::hbb8825661d997281
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/../../backtrace/src/backtrace/mod.rs:66
   2:     0x7f8e87a6d380 - std::sys_common::backtrace::_print_fmt::h26d850e2f7183914
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/sys_common/backtrace.rs:79
   3:     0x7f8e87a6d380 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3834b06f68a2b012
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/sys_common/backtrace.rs:58
   4:     0x7f8e87adbc0c - core::fmt::write::h3a043650ba7bf668
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/core/src/fmt/mod.rs:1082
   5:     0x7f8e87a5f6c7 - std::io::Write::write_fmt::h9c0c8944a1898139
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/io/mod.rs:1514
   6:     0x7f8e87a72030 - std::sys_common::backtrace::_print::h693c0c2cc41d4d10
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/sys_common/backtrace.rs:61
   7:     0x7f8e87a72030 - std::sys_common::backtrace::print::h213be73e5670b8ea
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/sys_common/backtrace.rs:48
   8:     0x7f8e87a72030 - std::panicking::default_hook::{{closure}}::h2d49a3361cc4e7ea
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/panicking.rs:200
   9:     0x7f8e87a71d7c - std::panicking::default_hook::hd41fbdeba93207ba
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/panicking.rs:219
  10:     0x7f8e882e9419 - rustc_driver::report_ice::hb57fcf9c0f585ed3
  11:     0x7f8e7b96b0c6 - <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call::hd2e9ad5b225448e0
                               at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1056
  12:     0x7f8e7b96ee35 - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h9a8b4e1b7d7b7151
                               at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:319
  13:     0x7f8e87a727d8 - std::panicking::rust_panic_with_hook::hcab398664b4bd473
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/panicking.rs:573
  14:     0x7f8e87a72389 - std::panicking::begin_panic_handler::{{closure}}::h7512c6f2998ba93d
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/panicking.rs:476
  15:     0x7f8e87a6d7ec - std::sys_common::backtrace::__rust_end_short_backtrace::h1a25d7e7e1864d3d
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/sys_common/backtrace.rs:153
  16:     0x7f8e87a72349 - rust_begin_unwind
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/panicking.rs:475
  17:     0x7f8e87a722fb - std::panicking::begin_panic_fmt::h8af3eb0f50edc2d0
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/panicking.rs:429
  18:     0x7f8e8a0f0d8a - rustc_metadata::rmeta::decoder::cstore_impl::<impl rustc_metadata::creader::CStore>::module_expansion_untracked::hf229b6c13e61f427
  19:     0x7f8e891f9a6d - rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver>::get_module::h1a23472d3fe1dc18
  20:     0x7f8e891f9a1c - rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver>::get_module::h1a23472d3fe1dc18
  21:     0x7f8e891f9e86 - rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver>::macro_def_scope::h4b47b2f0ff8473c9
  22:     0x7f8e8920cdaa - rustc_resolve::macros::<impl rustc_expand::base::ResolverExpand for rustc_resolve::Resolver>::resolve_macro_invocation::h65535b2f99bafce6
  23:     0x7f8e8a2ee111 - rustc_expand::expand::MacroExpander::fully_expand_fragment::h69c034c6d61249c8
  24:     0x7f8e8a2ed580 - rustc_expand::expand::MacroExpander::expand_crate::h8c2d8929612310ca
  25:     0x7f8e885bfe5c - rustc_session::utils::<impl rustc_session::session::Session>::time::haaf9a39853e2b108
  26:     0x7f8e8860fede - rustc_interface::passes::configure_and_expand_inner::hd880720adede20b1
  27:     0x7f8e885d82e9 - rustc_interface::passes::configure_and_expand::{{closure}}::h0e29c4151fbcfea0
  28:     0x7f8e885cd76f - rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new::hdfd7dbb0b9eb862c
  29:     0x7f8e8860eed5 - rustc_interface::passes::configure_and_expand::h0561e619d3ea6666
  30:     0x7f8e8865a408 - rustc_interface::queries::Queries::expansion::h03c4340e7e1e4bec
  31:     0x7f8e8830ccf7 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h037edd44e25c852a
  32:     0x7f8e882a2957 - rustc_span::with_source_map::h8bee9729eacaf0e5
  33:     0x7f8e8830e983 - rustc_interface::interface::create_compiler_and_run::hca1ea19f87aad490
  34:     0x7f8e882ed12a - scoped_tls::ScopedKey<T>::set::h98a472b48acc2e14
  35:     0x7f8e88301587 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0fbaefb3a51451a7
  36:     0x7f8e8828cf3e - core::ops::function::FnOnce::call_once{{vtable.shim}}::h7a49202ee8dc3a27
  37:     0x7f8e87a81d7a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h8a8db08de617a605
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/alloc/src/boxed.rs:1042
  38:     0x7f8e87a81d7a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hddfcff0ffd25c0c4
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/alloc/src/boxed.rs:1042
  39:     0x7f8e87a81d7a - std::sys::unix::thread::Thread::new::thread_start::h8e648f9ee2e9cb3a
                               at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/std/src/sys/unix/thread.rs:87
  40:     0x7f8e87974422 - start_thread
  41:     0x7f8e87892bf3 - __clone
  42:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.47.0-nightly (2d8a3b918 2020-08-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C target-cpu=native

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `safer-ffi`.

To learn more, run the command again with --verbose.

This ICE happens on:
rustc 1.47.0-beta.1 (0f91f5c28 2020-08-25)
rustc 1.47.0-nightly (2d8a3b918 2020-08-26)
but rustc 1.45.2 (d3fb005a3 2020-07-31) only shows a compiler error.

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 27, 2020
@jonas-schievink jonas-schievink added A-metadata Area: Crate metadata regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Aug 27, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 27, 2020
@spastorino
Copy link
Member

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@spastorino spastorino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 2, 2020
@danielhenrymantilla
Copy link
Contributor

danielhenrymantilla commented Oct 9, 2020

but rustc 1.45.2 (d3fb005a3 2020-07-31) only shows a compiler error.

This is because an integration test gets checked, which relies on the proc_macros feature to be enabled. Once it is enabled, 1.45.2 does not fail anymore, and yet the ICE persists 😬.

I'll thus kindly ask for this to be "re-prioritized", if possible, thanks.

@rustbot modify labels: +I-prioritize

@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 9, 2020
@camelid
Copy link
Member

camelid commented Oct 9, 2020

Assigning P-high and removing I-prioritize as discussed in the prioritization working group.

@camelid camelid added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. P-medium Medium priority labels Oct 9, 2020
@pnkfelix pnkfelix added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Oct 15, 2020
@spastorino
Copy link
Member

@rustbot ping cleanup

This needs mcve and bisection

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Oct 15, 2020
@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2020

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @JamesPatrickGill @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @shekohex @sinato @smmalis37 @spastorino @Stupremee @tamuhey @turboladen @woshilapin @yerke

@Stupremee
Copy link
Member

searched nightlies: from nightly-2020-07-20 to nightly-2020-08-25
regressed nightly: nightly-2020-07-28
searched commits: from 6c8927b to 76e8333
regressed commit: fa36f96

bisected with cargo-bisect-rustc v0.5.2

@Aaron1011 Aaron1011 self-assigned this Oct 15, 2020
@Aaron1011
Copy link
Member

Minimized:

// src/lib.rs
const _: () = {
    #[path = "foo.rs"]
    mod foo;
};

// src/foo.rs
#[macro_export]
macro_rules! my_macro {
    () => {}
}

// src/main.rs
fn main() {
    weird_path::my_macro!();
}

JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 25, 2020
…t, r=petrochenkov

Compute proper module parent during resolution

Fixes rust-lang#75982

The direct parent of a module may not be a module
(e.g. `const _: () =  { #[path = "foo.rs"] mod foo; };`).

To find the parent of a module for purposes of resolution, we need to
walk up the tree until we hit a module or a crate root.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metadata Area: Crate metadata C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants