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

dyn * ICE when used in constant and static #105777

Closed
DutchGhost opened this issue Dec 16, 2022 · 1 comment · Fixed by #109921
Closed

dyn * ICE when used in constant and static #105777

DutchGhost opened this issue Dec 16, 2022 · 1 comment · Fixed by #109921
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

@DutchGhost
Copy link
Contributor

Code

#![feature(dyn_star)]

const _: dyn* Send = &();
// static V: dyn* Send = Sync = &();

fn main() {}

Meta

rustc --version --verbose:

1.68.0 nightly

Error output

thread '<unnamed>' panicked at 'not implemented', compiler/rustc_const_eval/src/transform/check_consts/check.rs:559:17
Backtrace

thread '<unnamed>' panicked at 'not implemented', compiler/rustc_const_eval/src/transform/check_consts/check.rs:559:17
stack backtrace:
   0:     0x7f10b0a657da - std::backtrace_rs::backtrace::libunwind::trace::hc0c2c1a0c2b552f0
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f10b0a657da - std::backtrace_rs::backtrace::trace_unsynchronized::h4e8b186ae68c61b7
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f10b0a657da - std::sys_common::backtrace::_print_fmt::h61310913953cf43d
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f10b0a657da - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h89f946132e4203eb
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f10b0ac82ee - core::fmt::write::h6740f7d1bd8f4b51
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f10b0a55b65 - std::io::Write::write_fmt::h51db6b277caf7e91
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/io/mod.rs:1682:15
   6:     0x7f10b0a655a5 - std::sys_common::backtrace::_print::hc6a5f536e733a76e
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f10b0a655a5 - std::sys_common::backtrace::print::h8631c4f73218bc62
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f10b0a682ef - std::panicking::default_hook::{{closure}}::h3c780e5d293174cd
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/panicking.rs:267:22
   9:     0x7f10b0a6802b - std::panicking::default_hook::h309bb49de1e99fcb
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/panicking.rs:286:9
  10:     0x7f10b0a68b0c - std::panicking::rust_panic_with_hook::h6f5df507638c6c1f
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/panicking.rs:688:13
  11:     0x7f10b0a68862 - std::panicking::begin_panic_handler::{{closure}}::ha60489d3188eec52
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/panicking.rs:577:13
  12:     0x7f10b0a65c8c - std::sys_common::backtrace::__rust_end_short_backtrace::h3bdce2444d5d7dd7
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7f10b0a685b2 - rust_begin_unwind
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/panicking.rs:575:5
  14:     0x7f10b0ac4cd3 - core::panicking::panic_fmt::ha170bd6a13f0b251
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/core/src/panicking.rs:64:14
  15:     0x7f10b0ac4dad - core::panicking::panic::h54406099be7955b9
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/core/src/panicking.rs:111:5
  16:     0x7f10b2a4ae93 - <rustc_const_eval[155d61414e856197]::transform::check_consts::check::Checker as rustc_middle[c84b646c886cb2de]::mir::visit::Visitor>::visit_basic_block_data
  17:     0x7f10b2a485ab - <rustc_const_eval[155d61414e856197]::transform::check_consts::check::Checker>::check_body
  18:     0x7f10b2a45849 - rustc_mir_transform[9e86614eed3f7177]::mir_const_qualif
  19:     0x7f10b2a43e2b - rustc_query_system[877e705e9e61e210]::query::plumbing::try_execute_query::<rustc_query_impl[3eab8bca7a7ef5a]::plumbing::QueryCtxt, rustc_query_system[877e705e9e61e210]::query::caches::DefaultCache<rustc_span[543f1a391932d6c1]::def_id::DefId, rustc_middle[c84b646c886cb2de]::mir::query::ConstQualifs>>
  20:     0x7f10b2a40a12 - rustc_mir_transform[9e86614eed3f7177]::mir_promoted
  21:     0x7f10b2a3f2ca - rustc_query_system[877e705e9e61e210]::query::plumbing::try_execute_query::<rustc_query_impl[3eab8bca7a7ef5a]::plumbing::QueryCtxt, rustc_query_system[877e705e9e61e210]::query::caches::DefaultCache<rustc_middle[c84b646c886cb2de]::ty::WithOptConstParam<rustc_span[543f1a391932d6c1]::def_id::LocalDefId>, (&rustc_data_structures[453c30afbb1f2887]::steal::Steal<rustc_middle[c84b646c886cb2de]::mir::Body>, &rustc_data_structures[453c30afbb1f2887]::steal::Steal<rustc_index[c2e17390a6d6bf42]::vec::IndexVec<rustc_middle[c84b646c886cb2de]::mir::Promoted, rustc_middle[c84b646c886cb2de]::mir::Body>>)>>
  22:     0x7f10b2a3db1f - rustc_borrowck[862124a5633d3c1]::mir_borrowck
  23:     0x7f10b2cf9ece - rustc_query_system[877e705e9e61e210]::query::plumbing::try_execute_query::<rustc_query_impl[3eab8bca7a7ef5a]::plumbing::QueryCtxt, rustc_query_system[877e705e9e61e210]::query::caches::VecCache<rustc_span[543f1a391932d6c1]::def_id::LocalDefId, &rustc_middle[c84b646c886cb2de]::mir::query::BorrowCheckResult>>
  24:     0x7f10b2277508 - rustc_data_structures[453c30afbb1f2887]::sync::par_for_each_in::<&[rustc_span[543f1a391932d6c1]::def_id::LocalDefId], <rustc_middle[c84b646c886cb2de]::hir::map::Map>::par_body_owners<rustc_interface[a124a45dc0066a02]::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
  25:     0x7f10b2275733 - <rustc_session[c401c677e308d124]::session::Session>::time::<(), rustc_interface[a124a45dc0066a02]::passes::analysis::{closure#2}>
  26:     0x7f10b2273af7 - rustc_interface[a124a45dc0066a02]::passes::analysis
  27:     0x7f10b350fd07 - rustc_query_system[877e705e9e61e210]::query::plumbing::try_execute_query::<rustc_query_impl[3eab8bca7a7ef5a]::plumbing::QueryCtxt, rustc_query_system[877e705e9e61e210]::query::caches::DefaultCache<(), core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>>>
  28:     0x7f10b350fa00 - rustc_query_system[877e705e9e61e210]::query::plumbing::get_query::<rustc_query_impl[3eab8bca7a7ef5a]::queries::analysis, rustc_query_impl[3eab8bca7a7ef5a]::plumbing::QueryCtxt>
  29:     0x7f10b2f4d863 - <rustc_interface[a124a45dc0066a02]::passes::QueryContext>::enter::<rustc_driver[3259f56d7df430a3]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>>
  30:     0x7f10b2f49c13 - <rustc_interface[a124a45dc0066a02]::interface::Compiler>::enter::<rustc_driver[3259f56d7df430a3]::run_compiler::{closure#1}::{closure#2}, core[d5acfb63a27dd533]::result::Result<core[d5acfb63a27dd533]::option::Option<rustc_interface[a124a45dc0066a02]::queries::Linker>, rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>>
  31:     0x7f10b2f44c78 - rustc_span[543f1a391932d6c1]::with_source_map::<core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>, rustc_interface[a124a45dc0066a02]::interface::run_compiler<core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>, rustc_driver[3259f56d7df430a3]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  32:     0x7f10b2f44765 - <scoped_tls[f6bdf6b1b6fb927]::ScopedKey<rustc_span[543f1a391932d6c1]::SessionGlobals>>::set::<rustc_interface[a124a45dc0066a02]::interface::run_compiler<core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>, rustc_driver[3259f56d7df430a3]::run_compiler::{closure#1}>::{closure#0}, core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>>
  33:     0x7f10b2f43d52 - std[9df5139a5b73e852]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a124a45dc0066a02]::util::run_in_thread_pool_with_globals<rustc_interface[a124a45dc0066a02]::interface::run_compiler<core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>, rustc_driver[3259f56d7df430a3]::run_compiler::{closure#1}>::{closure#0}, core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>>
  34:     0x7f10b360a78e - <<std[9df5139a5b73e852]::thread::Builder>::spawn_unchecked_<rustc_interface[a124a45dc0066a02]::util::run_in_thread_pool_with_globals<rustc_interface[a124a45dc0066a02]::interface::run_compiler<core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>, rustc_driver[3259f56d7df430a3]::run_compiler::{closure#1}>::{closure#0}, core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d5acfb63a27dd533]::result::Result<(), rustc_errors[f10cbebfeb15a206]::ErrorGuaranteed>>::{closure#1} as core[d5acfb63a27dd533]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f10b4b1bb53 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf6d3bae8142574a3
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/alloc/src/boxed.rs:2000:9
  36:     0x7f10b4b1bb53 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::haf28aec72a86160e
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/alloc/src/boxed.rs:2000:9
  37:     0x7f10b4b1bb53 - std::sys::unix::thread::Thread::new::thread_start::hdd5296eb823f2d90
                               at /rustc/ec56537c4325ce5b798fc3628cbdd48ba4949ae5/library/std/src/sys/unix/thread.rs:108:17
  38:     0x7f10b0937609 - start_thread
  39:     0x7f10b085a133 - clone
  40:                0x0 - <unknown>
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground`; 1 warning emitted


@DutchGhost DutchGhost 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 Dec 16, 2022
@jruderman
Copy link
Contributor

Regression in nightly-2022-10-16 from #101832 (@compiler-errors)

Bisection method

I ran:

cargo-bisect-rustc --preserve --start 2020-01-01 --script ./shout.sh

with shout.sh:

! rustc --edition=2021 src/main.rs 2>&1 | grep -E "(internal compiler error)|(panicked)"

@compiler-errors compiler-errors self-assigned this Dec 16, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 17, 2022
Don't copy symbols from dylibs with `-Zdylib-lto`

When `rustc_driver` started being built with `-Zdylib-lto -Clto=thin`, some libstd symbols were copied by the LTO process into the dylib. That causes duplicate local symbols that are not present otherwise.

Depending on the situation (lib loading order apparently), the duplicated symbols could cause issues: `rustc_driver` overrode the panic hook, but it didn't apply to rustc main's hook (the default from libstd). This is the cause of rust-lang#105637, in some situations the panic hook installed by `rustc_driver` isn't executed, and only libstd's backtrace is shown (and a double panic). The query stack, as well as the various notes to open a GH about the ICE, don't appear.

It's not clear exactly what is needed to trigger the issue, but I have simulated a reproducer [here](https://github.com/lqd/issue-105637) with cargo involved, the incorrect panic hook is executed on my machine. It is hard to reproduce in a unit test: `cargo run` + `rustup` involves LD_LIBRARY_PATH, which is not the case for `compiletest`. cargo also adds unconditional flags that are then overridden in [`bootstrap` when building rustc with `rust.lto = thin`](https://github.com/rust-lang/rust/blob/9c07efe84f28a44f3044237696acc295aa407ee5/src/bootstrap/compile.rs#L702-L714) as done on CI).

All this to say the compilation and execution environment in `bootstrap` leading to the bug building `rustc_driver` is different from our UI tests, and I believe one of the reasons it's hard to make an exact reproducer test. Thankfully there's _still_ a difference in the behavior though: although in the unit test the correct panic hook seems to be executed compared to my repro and the current nightly, only the fix removes the double panic here.

The `7e8277aefa12f1469fb1df01418ff5846a7854a9` `try` build:
- fixes the reproducer repo linked above
- restores the ICE messages from rust-lang#105321 back to the state in its OP compared to the description in rust-lang#105637
- restores the ICE message and the query stack from rust-lang#105777 compared to nightly

While I believe this technically fixes the P-critical issue rust-lang#105637, I would not want to close it yet as we may want to backport to beta/stable (if a point release happens, it would fix the ICEs reported on 1.66.0, which is built with ThinLTO on linux). Once this PR lands, I'll also open another PR to re-enable ThinLTO on x64 darwin's dist builder.
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 22, 2022
@bors bors closed this as completed in 4b8725b Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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.

4 participants