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

rustc panic when trying to unwrap DistinctSources #63800

Closed
software-opal opened this issue Aug 22, 2019 · 8 comments · Fixed by #63859
Closed

rustc panic when trying to unwrap DistinctSources #63800

software-opal opened this issue Aug 22, 2019 · 8 comments · Fixed by #63859
Labels
A-borrow-checker Area: The borrow checker A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-NLL Area: Non-lexical lifetimes (NLL) 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.

Comments

@software-opal
Copy link

software-opal commented Aug 22, 2019

When trying to compile the tests for my code I get this error:

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("tests/macros.rs"), BytePos(2369)), end: (Macros("::archivelib::support::debug::check_rust_against_sys_decompress"), BytePos(8771655)) })', src/libcore/result.rs:999:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.37.0 (eae3437df 2019-08-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental -C link-arg=-fuse-ld=gold -C opt-level=0

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

error: Could not compile `archivelib`.
`RUST_BACKTRACE=full cargo test`
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("tests/macros.rs"), BytePos(2369)), end: (Macros("::archivelib::support::debug::check_rust_against_sys_decompress"), BytePos(8771655)) })', src/libcore/result.rs:999:5
stack backtrace:
   0:     0x7f2a2283636b - backtrace::backtrace::libunwind::trace::hfe5db90796807973                                                                                                                                                                                                                           at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1:     0x7f2a2283636b - backtrace::backtrace::trace_unsynchronized::h34b865a835594335
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2:     0x7f2a2283636b - std::sys_common::backtrace::_print::h527254ae44989167
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x7f2a2283636b - std::sys_common::backtrace::print::he85dd5ddddf46503
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x7f2a2283636b - std::panicking::default_hook::{{closure}}::h847a2eb38b396f14
                               at src/libstd/panicking.rs:200
   5:     0x7f2a22836047 - std::panicking::default_hook::h2ca0f9a30a0e206b
                               at src/libstd/panicking.rs:214
   6:     0x7f2a1fd83211 - rustc::util::common::panic_hook::hd4598aac709d8bd1
   7:     0x7f2a22836bc9 - std::panicking::rust_panic_with_hook::hffcefc09751839d1
                               at src/libstd/panicking.rs:481
   8:     0x7f2a22836662 - std::panicking::continue_panic_fmt::hc0f142c930c846fc
                               at src/libstd/panicking.rs:384
   9:     0x7f2a22836546 - rust_begin_unwind
                               at src/libstd/panicking.rs:311
  10:     0x7f2a22863dcd - core::panicking::panic_fmt::h2daf88b2616ca2b2
                               at src/libcore/panicking.rs:85
  11:     0x7f2a2139a5de - core::result::unwrap_failed::h6fc0053c9f46fa1a
  12:     0x7f2a2114a6d9 - rustc_mir::borrow_check::move_errors::<impl rustc_mir::borrow_check::MirBorrowckCtxt>::report::hf8f36da850a20b7c
  13:     0x7f2a21154cd8 - rustc_mir::borrow_check::do_mir_borrowck::hb7a693a299dea277
  14:     0x7f2a20ff89dd - rustc::ty::context::GlobalCtxt::enter_local::h07eff323eb978daa
  15:     0x7f2a2115332a - rustc_mir::borrow_check::mir_borrowck::h284fb7de9a37bcfa
  16:     0x7f2a21a772c7 - rustc::ty::query::__query_compute::mir_borrowck::hff15ac0e1f9f6137
  17:     0x7f2a21a87e35 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute::hee288ed314d409e6
  18:     0x7f2a21abcb60 - rustc::dep_graph::graph::DepGraph::with_task_impl::hf31f0af6331d7b71
  19:     0x7f2a21aa4f7a - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::hee29daf6559cca17
  20:     0x7f2a21a87cb3 - rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::hcfdff9dc5dadc257
  21:     0x7f2a21a4548e - rustc::util::common::time::hac94dadf7399ba87
  22:     0x7f2a21a001d2 - rustc_interface::passes::analysis::h39d33eb2a40812a3
  23:     0x7f2a22afa246 - rustc::ty::query::__query_compute::analysis::hf896d9719452bef1
  24:     0x7f2a22af9f99 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute::h314df7d2740153f0
  25:     0x7f2a22b8f138 - rustc::dep_graph::graph::DepGraph::with_task_impl::h5bfe7e398dba7700
  26:     0x7f2a22aff3be - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::hf803a152be45b4ee
  27:     0x7f2a22b00da6 - rustc::ty::context::tls::enter_global::h7f57e6c49574182e
  28:     0x7f2a22b052f7 - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h04fd22292950fbf4
  29:     0x7f2a21a4843a - rustc_interface::passes::create_global_ctxt::{{closure}}::h70f679c0b82043da
  30:     0x7f2a22b065f8 - rustc_interface::interface::run_compiler_in_existing_thread_pool::h1ee6f3bf0ba37faf
  31:     0x7f2a22b28d42 - std::thread::local::LocalKey<T>::with::h83b0a2026f4a2c6e
  32:     0x7f2a22b3c891 - scoped_tls::ScopedKey<T>::set::h47171c9859321621
  33:     0x7f2a22b548b4 - syntax::with_globals::h7dd1a1171ce8a4bf
  34:     0x7f2a22b7fb1d - std::sys_common::backtrace::__rust_begin_short_backtrace::h1ed9f0eaa05c0996
  35:     0x7f2a2284748a - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:82
  36:     0x7f2a22b08cc9 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h3b9a37e8ad92df6e
  37:     0x7f2a22819e0f - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h42806b83647d4c79
                               at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/liballoc/boxed.rs:746
  38:     0x7f2a22846170 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h83c921c8e826dd1d
                               at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/liballoc/boxed.rs:746
  39:     0x7f2a22846170 - std::sys_common::thread::start_thread::h2613204ce513782e
                               at src/libstd/sys_common/thread.rs:13
  40:     0x7f2a22846170 - std::sys::unix::thread::Thread::new::thread_start::h4570080769500bcd
                               at src/libstd/sys/unix/thread.rs:79
  41:     0x7f2a225a76db - start_thread
  42:     0x7f2a21ea188f - __clone
  43:                0x0 - <unknown>
query stack during panic:
#0 [mir_borrowck] processing `short_sample::test_decompress_level_0`                                                                                                                                                                                                            #1 [analysis] running analysis passes on this crate                                                                                                                                                                                                                             end of query stack
                                                                                                                                                                                                                                                                                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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.37.0 (eae3437df 2019-08-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental -C link-arg=-fuse-ld=gold -C opt-level=0

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

error: Could not compile `archivelib`.                      

My understanding is that the compiler was trying to tell me about a borrow checker error; but I have no idea where to start minimizing this error(sorry).

@hellow554
Copy link
Contributor

hellow554 commented Aug 22, 2019

I have managed to get it down to two files:

lib.rs:

#[macro_use]
mod ext;

struct A;

macro_rules! sss {
    () => {
        #[test]
        fn fff() {
            static D: A = A;
            aaa!(D);
        }
    };
}

sss!();

ext.rs

macro_rules! aaa {
    ($c:ident) => {{
        let a = $c;
    }}
}

It doesn't work with a mod in the lib.rs, it has to be a different file. cargo test is then needed to trigger the ICE.

@hellow554

This comment has been minimized.

@rustbot rustbot added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) 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 22, 2019
@Centril
Copy link
Contributor

Centril commented Aug 22, 2019

cc @matthewjasper

@hellow554
Copy link
Contributor

Seems to be related to 2018 edition? If I use the nightly-2018-10-01 and execute rustc src/lib.rs --test --edition=2015 it doesn't ICE, but with rustc src/lib.rs --test --edition=2018 it does ICE. well...

@Centril
Copy link
Contributor

Centril commented Aug 22, 2019

Most likely related to the fact that NLL is active in Rust 2018 then.

@jonas-schievink jonas-schievink added A-borrow-checker Area: The borrow checker A-NLL Area: Non-lexical lifetimes (NLL) labels Aug 22, 2019
@hellow554
Copy link
Contributor

Bisecting: Somewhere in d767ee1...b202882

@hellow554
Copy link
Contributor

hellow554 commented Aug 22, 2019

Most likely related to the fact that NLL is active in Rust 2018 then.

Confirmed. #![feature(nll)] gave me the ICE on 2015 as well (forgot that in the good ol' days nll was not a thing)
Also confirmed, that edition 2015 does ICE with feature(nll) on b202882 and not on d767ee1 (like edition 2018 did above).

@hellow554
Copy link
Contributor

hellow554 commented Aug 22, 2019

Also ICE with -Z polonius

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("src/lib.rs"), BytePos(0)), end: (Real("src/ext.rs"), BytePos(179)) })', src/libcore/result.rs:1084:5
stack backtrace:
   0:     0x7fd5a7664742 - backtrace::backtrace::libunwind::trace::h5b672ea0408452ed
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.35/src/backtrace/libunwind.rs:88
   1:     0x7fd5a7664742 - backtrace::backtrace::trace_unsynchronized::h15bbd54ccd30253c
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.35/src/backtrace/mod.rs:66
   2:     0x7fd5a7664742 - std::sys_common::backtrace::_print::hbf32a02f9894e727
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x7fd5a7664742 - std::sys_common::backtrace::print::h127d55b04a8ca638
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x7fd5a7664742 - std::panicking::default_hook::{{closure}}::h41569aa1cabd15f2
                               at src/libstd/panicking.rs:200
   5:     0x7fd5a7664426 - std::panicking::default_hook::h2471d95c3baf1435
                               at src/libstd/panicking.rs:214
   6:     0x7fd5a9520331 - rustc::util::common::panic_hook::h2022bda27bb76336
   7:     0x7fd5a7664f7c - std::panicking::rust_panic_with_hook::hdb74b1d76abfd8b2
                               at src/libstd/panicking.rs:481
   8:     0x7fd5a7664a32 - std::panicking::continue_panic_fmt::h7aad477695105344
                               at src/libstd/panicking.rs:384
   9:     0x7fd5a7664926 - rust_begin_unwind
                               at src/libstd/panicking.rs:311
  10:     0x7fd5a76917ba - core::panicking::panic_fmt::h2a7634fba4671b05
                               at src/libcore/panicking.rs:85
  11:     0x7fd5a76919f7 - core::result::unwrap_failed::h395c34a928fec133
                               at src/libcore/result.rs:1084
  12:     0x7fd5a84e91b5 - rustc_mir::borrow_check::move_errors::<impl rustc_mir::borrow_check::MirBorrowckCtxt>::report::h25a9cf486d5266a9
  13:     0x7fd5a84f1b4b - rustc_mir::borrow_check::do_mir_borrowck::hda4dab5518004986
  14:     0x7fd5a85ab923 - rustc::ty::context::GlobalCtxt::enter_local::h7429ee56447ea8af
  15:     0x7fd5a84f00de - rustc_mir::borrow_check::mir_borrowck::h85ba4c70317d3291
  16:     0x7fd5a7c04ac2 - rustc::ty::query::__query_compute::mir_borrowck::h98fb41102a77b5f0
  17:     0x7fd5a7cd1c3c - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute::h9802436be570eac8
  18:     0x7fd5a7cffcc4 - rustc::dep_graph::graph::DepGraph::with_task_impl::h72798b490d7dda9f
  19:     0x7fd5a7ce2b53 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h923529f6824dea4f
  20:     0x7fd5a7cd1b1d - rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::h61fa4efa258d8006
  21:     0x7fd5a7ca152c - rustc::util::common::time::h3cf71e821181dc48
  22:     0x7fd5a7c486da - rustc_interface::passes::analysis::h9f50cf021540f6a4
  23:     0x7fd5a7b29291 - rustc::ty::query::__query_compute::analysis::he59e8eea93928c08
  24:     0x7fd5a7b39d1d - rustc::dep_graph::graph::DepGraph::with_task_impl::h6dea995610f354d4
  25:     0x7fd5a7b460de - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h68b2231d3424095f
  26:     0x7fd5a7b652a5 - rustc::ty::context::tls::enter_global::he96502a63341a2b8
  27:     0x7fd5a7b4c487 - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h9e5505cac0dd4781
  28:     0x7fd5a7ca650a - rustc_interface::passes::create_global_ctxt::{{closure}}::h63fdbd27f3ec6fd7
  29:     0x7fd5a7b4e68e - rustc_interface::interface::run_compiler_in_existing_thread_pool::h9e1e785d8bd30ef2
  30:     0x7fd5a7b87412 - std::thread::local::LocalKey<T>::with::hd628004bbe9136f1
  31:     0x7fd5a7b8ef3e - scoped_tls::ScopedKey<T>::set::hb63f3a057333c317
  32:     0x7fd5a7bc07f2 - syntax::with_globals::he4a92d8220bc2e1b
  33:     0x7fd5a7b1ec52 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd1bf2fb1e8e27b88
  34:     0x7fd5a767583a - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  35:     0x7fd5a7b50209 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h2a4f847e90febcd1
  36:     0x7fd5a764840f - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h63427f5093f1aac0
                               at /rustc/e44fdf97929d1315add3b76208adf99e8299252d/src/liballoc/boxed.rs:922
  37:     0x7fd5a76744c0 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h398cbfcb305a969f
                               at /rustc/e44fdf97929d1315add3b76208adf99e8299252d/src/liballoc/boxed.rs:922
  38:     0x7fd5a76744c0 - std::sys_common::thread::start_thread::h55519c3a5f7d36e1
                               at src/libstd/sys_common/thread.rs:13
  39:     0x7fd5a76744c0 - std::sys::unix::thread::Thread::new::thread_start::hace5e416996b8e04
                               at src/libstd/sys/unix/thread.rs:79
  40:     0x7fd5a75b375a - start_thread
  41:     0x7fd5a74ca9f3 - __clone
  42:                0x0 - <unknown>
query stack during panic:
#0 [mir_borrowck] processing `fff`
#1 [analysis] running analysis passes on this crate
end of query stack

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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.39.0-nightly (e44fdf979 2019-08-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z polonius

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-NLL Area: Non-lexical lifetimes (NLL) 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants