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: unsized_tuple_coercion with debuginfo=2 #93871

Closed
matthiaskrgr opened this issue Feb 10, 2022 · 6 comments · Fixed by #94050
Closed

ICE: unsized_tuple_coercion with debuginfo=2 #93871

matthiaskrgr opened this issue Feb 10, 2022 · 6 comments · Fixed by #94050
Assignees
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) 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) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Feb 10, 2022

Code

code from ./src/tools/miri/tests/run-pass/unsized-tuple-impls.rs

#![feature(unsized_tuple_coercion)]
fn main() {
    let x : &(i32, i32, [i32]) = &(0, 1, [2, 3]);
}

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (e7aca8959 2022-02-09)
binary: rustc
commit-hash: e7aca895980f25f6d2d3c48e10fd04656764d1e4
commit-date: 2022-02-09
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0

Error output

rustc ./src/tools/miri/tests/run-pass/unsized-tuple-impls.rs -Cdebuginfo=2

warning: unused variable: `x`
 --> ./src/tools/miri/tests/run-pass/unsized-tuple-impls.rs:3:9
  |
3 |     let x : &(i32, i32, [i32]) = &(0, 1, [2, 3]);
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

thread 'rustc' panicked at 'fat_pointer_kind() - Encountered unexpected `pointee_ty`: (i32, i32, [i32])', compiler/rustc_codegen_llvm/src/debuginfo/utils.rs:102:13
Backtrace

thread 'rustc' panicked at 'fat_pointer_kind() - Encountered unexpected `pointee_ty`: (i32, i32, [i32])', compiler/rustc_codegen_llvm/src/debuginfo/utils.rs:102:13
stack backtrace:
   0:     0x7f4ac58b3b6c - std::backtrace_rs::backtrace::libunwind::trace::h824347123a539ac3
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f4ac58b3b6c - std::backtrace_rs::backtrace::trace_unsynchronized::h30996243a6d4a816
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4ac58b3b6c - std::sys_common::backtrace::_print_fmt::he0e84aa8853fdb2a
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f4ac58b3b6c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h699cf46bd548daad
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f4ac591524c - core::fmt::write::hc21dca261faff02f
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f4ac58a3e98 - std::io::Write::write_fmt::ha562dab75b1aee7a
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/io/mod.rs:1657:15
   6:     0x7f4ac58b7ae7 - std::sys_common::backtrace::_print::h6995311cb4b18c83
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f4ac58b7ae7 - std::sys_common::backtrace::print::h5c00a73bc75b17c4
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f4ac58b7ae7 - std::panicking::default_hook::{{closure}}::he5c22156c1cfda73
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/panicking.rs:295:22
   9:     0x7f4ac58b77af - std::panicking::default_hook::hd9340e2830e1e464
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/panicking.rs:314:9
  10:     0x7f4ac6044d91 - rustc_driver[f7ae5b3e036b262e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f4ac58b83c5 - std::panicking::rust_panic_with_hook::hb17e9d2f86437995
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/panicking.rs:702:17
  12:     0x7f4ac58b8077 - std::panicking::begin_panic_handler::{{closure}}::h5ea470c57cd887ae
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/panicking.rs:588:13
  13:     0x7f4ac58b4014 - std::sys_common::backtrace::__rust_end_short_backtrace::hdf89f68b6e6aa66b
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f4ac58b7d79 - rust_begin_unwind
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/panicking.rs:584:5
  15:     0x7f4ac587fd03 - core::panicking::panic_fmt::h0b506cc131461e16
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/core/src/panicking.rs:143:14
  16:     0x7f4ac72c51fa - rustc_codegen_llvm[de3b2ae653c2b26d]::debuginfo::utils::fat_pointer_kind
  17:     0x7f4ac72a2d3a - rustc_codegen_llvm[de3b2ae653c2b26d]::debuginfo::metadata::pointer_or_reference_metadata
  18:     0x7f4ac72a3aa4 - rustc_codegen_llvm[de3b2ae653c2b26d]::debuginfo::metadata::type_metadata
  19:     0x7f4ac72ec3c5 - rustc_codegen_ssa[f8a21cda5309aefe]::mir::codegen_mir::<rustc_codegen_llvm[de3b2ae653c2b26d]::builder::Builder>
  20:     0x7f4ac72b0212 - rustc_codegen_llvm[de3b2ae653c2b26d]::base::compile_codegen_unit::module_codegen
  21:     0x7f4ac7f43ec6 - <rustc_query_system[fb683e47e947d40]::dep_graph::graph::DepGraph<rustc_middle[69fe71bd9bb50da9]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[69fe71bd9bb50da9]::ty::context::TyCtxt, rustc_span[eca3046f9c14e76]::symbol::Symbol, rustc_codegen_ssa[f8a21cda5309aefe]::ModuleCodegen<rustc_codegen_llvm[de3b2ae653c2b26d]::ModuleLlvm>>
  22:     0x7f4ac7f2b51e - rustc_codegen_llvm[de3b2ae653c2b26d]::base::compile_codegen_unit
  23:     0x7f4ac7f4791a - rustc_codegen_ssa[f8a21cda5309aefe]::base::codegen_crate::<rustc_codegen_llvm[de3b2ae653c2b26d]::LlvmCodegenBackend>
  24:     0x7f4ac7f621da - <rustc_codegen_llvm[de3b2ae653c2b26d]::LlvmCodegenBackend as rustc_codegen_ssa[f8a21cda5309aefe]::traits::backend::CodegenBackend>::codegen_crate
  25:     0x7f4ac7eeb9a7 - <rustc_session[e825f980c6f8a293]::session::Session>::time::<alloc[14a0d6d4553afc6a]::boxed::Box<dyn core[b9efde14e06b09ed]::any::Any>, rustc_interface[f21518ebe01ac716]::passes::start_codegen::{closure#0}>
  26:     0x7f4ac7f1597c - <rustc_interface[f21518ebe01ac716]::passes::QueryContext>::enter::<<rustc_interface[f21518ebe01ac716]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[b9efde14e06b09ed]::result::Result<alloc[14a0d6d4553afc6a]::boxed::Box<dyn core[b9efde14e06b09ed]::any::Any>, rustc_errors[59c9bb132555b663]::ErrorReported>>
  27:     0x7f4ac7efebef - <rustc_interface[f21518ebe01ac716]::queries::Queries>::ongoing_codegen
  28:     0x7f4ac7ecd831 - rustc_interface[f21518ebe01ac716]::interface::create_compiler_and_run::<core[b9efde14e06b09ed]::result::Result<(), rustc_errors[59c9bb132555b663]::ErrorReported>, rustc_driver[f7ae5b3e036b262e]::run_compiler::{closure#1}>
  29:     0x7f4ac7eb38a2 - std[1e60cef5fcfeb639]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f21518ebe01ac716]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[f21518ebe01ac716]::interface::run_compiler<core[b9efde14e06b09ed]::result::Result<(), rustc_errors[59c9bb132555b663]::ErrorReported>, rustc_driver[f7ae5b3e036b262e]::run_compiler::{closure#1}>::{closure#0}, core[b9efde14e06b09ed]::result::Result<(), rustc_errors[59c9bb132555b663]::ErrorReported>>::{closure#0}, core[b9efde14e06b09ed]::result::Result<(), rustc_errors[59c9bb132555b663]::ErrorReported>>
  30:     0x7f4ac7ee4309 - <<std[1e60cef5fcfeb639]::thread::Builder>::spawn_unchecked_<rustc_interface[f21518ebe01ac716]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[f21518ebe01ac716]::interface::run_compiler<core[b9efde14e06b09ed]::result::Result<(), rustc_errors[59c9bb132555b663]::ErrorReported>, rustc_driver[f7ae5b3e036b262e]::run_compiler::{closure#1}>::{closure#0}, core[b9efde14e06b09ed]::result::Result<(), rustc_errors[59c9bb132555b663]::ErrorReported>>::{closure#0}, core[b9efde14e06b09ed]::result::Result<(), rustc_errors[59c9bb132555b663]::ErrorReported>>::{closure#1} as core[b9efde14e06b09ed]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7f4ac58c3e13 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6b24c31e6604f724
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/alloc/src/boxed.rs:1854:9
  32:     0x7f4ac58c3e13 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h357a4d585864792d
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/alloc/src/boxed.rs:1854:9
  33:     0x7f4ac58c3e13 - std::sys::unix::thread::Thread::new::thread_start::h571ee483c9a2c616
                               at /rustc/e7aca895980f25f6d2d3c48e10fd04656764d1e4/library/std/src/sys/unix/thread.rs:108:17
  34:     0x7f4ac57c9259 - start_thread
  35:     0x7f4ac56e55e3 - __GI___clone
  36:                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.60.0-nightly (e7aca8959 2022-02-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2

query stack during panic:
end of query stack
warning: 1 warning emitted

@matthiaskrgr matthiaskrgr added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) 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. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. labels Feb 10, 2022
@wesleywiser
Copy link
Member

cc @michaelwoerister
It looks like this might be related to #93006

@pnkfelix
Copy link
Member

pnkfelix commented Feb 10, 2022

cargo-bisect-rustc reports that this is regression in 427eba2 (which is indeed in PR #93006).

@pnkfelix
Copy link
Member

pnkfelix commented Feb 10, 2022

@matthiaskrgr reports in zulip that this test case fails at that same injection point when combined with -Cdebuginfo=2 (aka -g):

./src/test/run-pass-valgrind/dst-dtor-4.rs :

Content of above file
#![feature(unsized_tuple_coercion)]

static mut DROP_RAN: isize = 0;

struct Foo;
impl Drop for Foo {
    fn drop(&mut self) {
        unsafe { DROP_RAN += 1; }
    }
}

pub fn main() {
    {
        let _x: Box<(i32, [Foo])> = Box::<(i32, [Foo; 3])>::new((42, [Foo, Foo, Foo]));
    }
    unsafe {
        assert_eq!(DROP_RAN, 3);
    }
}

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Feb 10, 2022

Files that reproduce the ice one way or another with -Cdebuginfo=2 :

./src/tools/miri/tests/run-pass/unsized-tuple-impls.rs
./src/test/run-pass-valgrind/dst-dtor-4.rs
./src/test/ui/dynamically-sized-types/dst-raw.rs
./src/test/ui/dynamically-sized-types/dst-tuple.rs
./src/test/ui/unsized-locals/unsized-exprs-rpass.rs
./src/test/ui/dynamically-sized-types/dst-trait-tuple.rs
./src/test/ui/dynamically-sized-types/dst-tuple-no-reorder.rs
./src/test/ui/dynamically-sized-types/dst-tuple-zst-offsets.rs
./src/test/ui/dynamically-sized-types/dst-tuple-sole.rs
./src/test/ui/dynamically-sized-types/dst-irrefutable-bind.rs
./src/test/ui/unsized/unsized-tuple-impls.rs

@michaelwoerister michaelwoerister self-assigned this Feb 11, 2022
@michaelwoerister
Copy link
Member

Thanks for the bug report, @matthiaskrgr! I'll look into it.

@michaelwoerister
Copy link
Member

Looks like this should be an easy fix. The code just doesn't expect tuples to be unsized (which of course it should).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) 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) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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