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: !tcx.is_mutable_static(def_id) (#[linkage = "weak"]) #1473

Open
matthiaskrgr opened this issue Mar 30, 2024 · 2 comments
Open

ICE: !tcx.is_mutable_static(def_id) (#[linkage = "weak"]) #1473

matthiaskrgr opened this issue Mar 30, 2024 · 2 comments

Comments

@matthiaskrgr
Copy link
Member

from rust-lang/rust#59062
auto-reduced (treereduce-rust):

#![feature(linkage)]

fn main() {
    extern "C" {
        #[linkage = "weak"]
        static mut ABC: *const u8;
    }

    unsafe {
        assert_eq!(ABC as usize, 0);
    }
}

original:

#![feature(linkage)]

fn main() {
    extern {
        #[linkage = "weak"]
        static mut ABC: *const u8;
    }

    {
        #[no_mangle]
        static mut ABC: *const u8 = 1 as *const u8;
    }

    unsafe { assert_eq!(ABC as usize, 0); }
}

Version information

rustc 1.79.0-nightly (185272822 2024-03-30)
binary: rustc
commit-hash: 18527282244431f597720e4fd42199e7333cc1c1
commit-date: 2024-03-30
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=cranelift

Program output

thread 'rustc' panicked at src/constant.rs:261:9:
assertion failed: !tcx.is_mutable_static(def_id)
stack backtrace:
   0:     0x7f791b3866c5 - std::backtrace_rs::backtrace::libunwind::trace::h0dde1465b66e0bbc
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f791b3866c5 - std::backtrace_rs::backtrace::trace_unsynchronized::hfe1fbe70eccd30a7
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f791b3866c5 - std::sys_common::backtrace::_print_fmt::h093790065b26d328
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f791b3866c5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha34c60e89bc4531b
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f791b3d774b - core::fmt::rt::Argument::fmt::hc7e61bdecc1e0748
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/core/src/fmt/rt.rs:142:9
   5:     0x7f791b3d774b - core::fmt::write::hbd62fdf3779f1b5a
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f791b37b2af - std::io::Write::write_fmt::h5b34811db09ed959
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/io/mod.rs:1843:15
   7:     0x7f791b38649e - std::sys_common::backtrace::_print::h018740f65ebbf245
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f791b38649e - std::sys_common::backtrace::print::ha5e754e67506bcfd
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f791b389149 - std::panicking::default_hook::{{closure}}::h66e1a9082dba1e8f
  10:     0x7f791b388eb3 - std::panicking::default_hook::h296fda7c69396aaa
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/panicking.rs:292:9
  11:     0x7f7917bf7a4f - std[28cea44e47f92da2]::panicking::update_hook::<alloc[6d832cc9f97713f4]::boxed::Box<rustc_driver_impl[7ce072e57cf39d0d]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f791b38984c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8e07c02829834f4a
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/alloc/src/boxed.rs:2032:9
  13:     0x7f791b38984c - std::panicking::rust_panic_with_hook::ha6b791a790e4c8b6
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/panicking.rs:793:13
  14:     0x7f791b3895bd - std::panicking::begin_panic_handler::{{closure}}::h4eba7e6fa99311de
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/panicking.rs:650:13
  15:     0x7f791b386b89 - std::sys_common::backtrace::__rust_end_short_backtrace::h705dfb32fd592b93
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f791b389327 - rust_begin_unwind
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/panicking.rs:646:5
  17:     0x7f791b3d3be6 - core::panicking::panic_fmt::h29357ebd2965afeb
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/core/src/panicking.rs:72:14
  18:     0x7f791b3d3c8f - core::panicking::panic::h365c582d07c99abc
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/core/src/panicking.rs:141:5
  19:     0x7f790ae1e59a - rustc_codegen_cranelift[f331086d87cfdf90]::constant::data_id_for_static
  20:     0x7f790ae1cef1 - rustc_codegen_cranelift[f331086d87cfdf90]::constant::codegen_const_value
  21:     0x7f790ae1580b - rustc_codegen_cranelift[f331086d87cfdf90]::base::codegen_operand
  22:     0x7f790ae0bb45 - rustc_codegen_cranelift[f331086d87cfdf90]::base::codegen_fn_body
  23:     0x7f790ae28b6d - rustc_codegen_cranelift[f331086d87cfdf90]::driver::aot::module_codegen::{closure#0}
  24:     0x7f790ae24f17 - rustc_codegen_cranelift[f331086d87cfdf90]::driver::aot::module_codegen
  25:     0x7f790ae32209 - rustc_codegen_cranelift[f331086d87cfdf90]::driver::aot::run_aot
  26:     0x7f790ae60e91 - <rustc_codegen_cranelift[f331086d87cfdf90]::CraneliftCodegenBackend as rustc_codegen_ssa[7109f377bf2e1a93]::traits::backend::CodegenBackend>::codegen_crate
  27:     0x7f7919efa145 - rustc_interface[d75395f7b223fbcb]::passes::start_codegen
  28:     0x7f7919ef97b4 - <rustc_interface[d75395f7b223fbcb]::queries::Queries>::codegen_and_build_linker
  29:     0x7f7919c9a7c4 - rustc_interface[d75395f7b223fbcb]::interface::run_compiler::<core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>, rustc_driver_impl[7ce072e57cf39d0d]::run_compiler::{closure#0}>::{closure#0}
  30:     0x7f7919d6627f - std[28cea44e47f92da2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d75395f7b223fbcb]::util::run_in_thread_with_globals<rustc_interface[d75395f7b223fbcb]::util::run_in_thread_pool_with_globals<rustc_interface[d75395f7b223fbcb]::interface::run_compiler<core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>, rustc_driver_impl[7ce072e57cf39d0d]::run_compiler::{closure#0}>::{closure#0}, core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>>::{closure#0}, core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>>
  31:     0x7f7919d66072 - <<std[28cea44e47f92da2]::thread::Builder>::spawn_unchecked_<rustc_interface[d75395f7b223fbcb]::util::run_in_thread_with_globals<rustc_interface[d75395f7b223fbcb]::util::run_in_thread_pool_with_globals<rustc_interface[d75395f7b223fbcb]::interface::run_compiler<core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>, rustc_driver_impl[7ce072e57cf39d0d]::run_compiler::{closure#0}>::{closure#0}, core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>>::{closure#0}, core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bfe4fde843a20040]::result::Result<(), rustc_span[22d215cff5c0359c]::ErrorGuaranteed>>::{closure#1} as core[bfe4fde843a20040]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f791b3931a9 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h391ddcf1e8250910
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/alloc/src/boxed.rs:2018:9
  33:     0x7f791b3931a9 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha0b3833bb294e634
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/alloc/src/boxed.rs:2018:9
  34:     0x7f791b3931a9 - std::sys::pal::unix::thread::Thread::new::thread_start::hba2d16457fd4959d
                               at /rustc/18527282244431f597720e4fd42199e7333cc1c1/library/std/src/sys/pal/unix/thread.rs:108:17
  35:     0x7f791b13155a - <unknown>
  36:     0x7f791b1aea3c - <unknown>
  37:                0x0 - <unknown>

error: 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.79.0-nightly (185272822 2024-03-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z codegen-backend=cranelift -Z dump-mir-dir=dir

query stack during panic:
end of query stack

@bjorn3
Copy link
Member

bjorn3 commented Mar 31, 2024

Looks like cg_llvm ignores the mut entirely.

@bjorn3
Copy link
Member

bjorn3 commented May 12, 2024

rust-lang/rust#125046 will make rustc error out on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants