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: linkage: Fn(Instance { def: Item(DefId(0:7 ~ mvce[4fbb]::{impl#0}::bar)), args: [] }) = LinkOnceAny Default #1454

Closed
matthiaskrgr opened this issue Jan 31, 2024 · 1 comment

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

#![feature(linkage)]
macro_rules! make_method {
    ($name:ident) => {
        fn $name(&self) {}
    };
}

struct S;

impl S {
    make_method!(foo1);
    make_method!(foo2);
    make_method!(foo3);
    make_method!(enumerated_loop);
    make_method!(foo5);
    make_method!(foo6);
    make_method!(foo7);
    make_method!(foo8);

    #[linkage = "linkonce"]
    fn bar(&self) {}
}

fn main() {}

original:

// forbid-output: in this expansion of

macro_rules! make_method {
    ($name:ident) => ( fn $name(&self) { } )
}

struct S;

impl S {
    // We had a bug where these wouldn't clean up macro backtrace frames.
    make_method!(foo1);
    make_method!(foo2);
    make_method!(foo3);
    make_method!(enumerated_loop);
    make_method!(foo5);
    make_method!(foo6);
    make_method!(foo7);
    make_method!(foo8);

    // Cause an error. It shouldn't have any macro backtrace frames.
    #[linkage = "linkonce"]
    fn bar(&self) { } //~ ERROR duplicate definitions
}

fn main() { }

Version information

rustc 1.77.0-nightly (cb4d9a190 2024-01-30)
binary: rustc
commit-hash: cb4d9a1902b3ea17e93872dafb76d24aa6295c47
commit-date: 2024-01-30
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=cranelift -Zcrate-attr=feature(linkage)

Program output

warning: multiple methods are never used
  --> /tmp/icemaker_global_tempdir.d4xai4xLh1Kp/rustc_testrunner_tmpdir_reporting.6DxIvIUdNYZq/mvce.rs:10:18
   |
9  | impl S {
   | ------ methods in this implementation
10 |     make_method!(foo1);
   |                  ^^^^
11 |     make_method!(foo2);
   |                  ^^^^
12 |     make_method!(foo3);
   |                  ^^^^
13 |     make_method!(enumerated_loop);
   |                  ^^^^^^^^^^^^^^^
14 |     make_method!(foo5);
   |                  ^^^^
15 |     make_method!(foo6);
   |                  ^^^^
16 |     make_method!(foo7);
   |                  ^^^^
17 |     make_method!(foo8);
   |                  ^^^^
   |
   = note: `#[warn(dead_code)]` on by default
   = note: this warning originates in the macro `make_method` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at src/linkage.rs:17:14:
Fn(Instance { def: Item(DefId(0:7 ~ mvce[4fbb]::{impl#0}::bar)), args: [] }) = LinkOnceAny Default
stack backtrace:
   0:     0x7fc51038bd16 - std::backtrace_rs::backtrace::libunwind::trace::ha1ffb427d146be06
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fc51038bd16 - std::backtrace_rs::backtrace::trace_unsynchronized::h3233e8c5c99079a0
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fc51038bd16 - std::sys_common::backtrace::_print_fmt::ha09c54c73dc31523
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fc51038bd16 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb575efd12cb49bf9
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fc5103de770 - core::fmt::rt::Argument::fmt::hfa005e844bc9fe43
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/core/src/fmt/rt.rs:142:9
   5:     0x7fc5103de770 - core::fmt::write::h559fda85dc6292c4
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fc51037f61f - std::io::Write::write_fmt::h48410cf63c4d622c
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/io/mod.rs:1846:15
   7:     0x7fc51038baf4 - std::sys_common::backtrace::_print::heaf546ff60bf3821
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fc51038baf4 - std::sys_common::backtrace::print::h52cc0b68730fd3bf
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fc51038e887 - std::panicking::default_hook::{{closure}}::h9cc287dacf0db228
  10:     0x7fc51038e5e9 - std::panicking::default_hook::hf0eb17b9efad4d83
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/panicking.rs:292:9
  11:     0x7fc513133bfc - std[b17d18de645d14f5]::panicking::update_hook::<alloc[20182062dab2cff7]::boxed::Box<rustc_driver_impl[a7afd08560397dfd]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fc51038efd6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2072764c87311d5c
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/alloc/src/boxed.rs:2029:9
  13:     0x7fc51038efd6 - std::panicking::rust_panic_with_hook::h8c15e55009b1f0cd
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/panicking.rs:785:13
  14:     0x7fc51038ed22 - std::panicking::begin_panic_handler::{{closure}}::h91ecb7a781b19fc7
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/panicking.rs:659:13
  15:     0x7fc51038c216 - std::sys_common::backtrace::__rust_end_short_backtrace::h7612bfc645f63d2f
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fc51038ea74 - rust_begin_unwind
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/panicking.rs:647:5
  17:     0x7fc5103dae75 - core::panicking::panic_fmt::h4f89a8cc63569575
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/core/src/panicking.rs:72:14
  18:     0x7fc506a2492d - rustc_codegen_cranelift[5d5cbd9a7cdfbfcb]::driver::aot::module_codegen::{closure#0}
  19:     0x7fc506a1fe72 - rustc_codegen_cranelift[5d5cbd9a7cdfbfcb]::driver::aot::module_codegen
  20:     0x7fc506a2c9df - rustc_codegen_cranelift[5d5cbd9a7cdfbfcb]::driver::aot::run_aot
  21:     0x7fc506a5bcdc - <rustc_codegen_cranelift[5d5cbd9a7cdfbfcb]::CraneliftCodegenBackend as rustc_codegen_ssa[b33049d2c07eb74d]::traits::backend::CodegenBackend>::codegen_crate
  22:     0x7fc515393a70 - rustc_interface[c7c8f488c1d96c6d]::passes::start_codegen
  23:     0x7fc5153931b0 - <rustc_interface[c7c8f488c1d96c6d]::queries::Queries>::codegen_and_build_linker
  24:     0x7fc51511458c - rustc_interface[c7c8f488c1d96c6d]::interface::run_compiler::<core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>, rustc_driver_impl[a7afd08560397dfd]::run_compiler::{closure#0}>::{closure#0}
  25:     0x7fc514da755a - std[b17d18de645d14f5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c7c8f488c1d96c6d]::util::run_in_thread_with_globals<rustc_interface[c7c8f488c1d96c6d]::util::run_in_thread_pool_with_globals<rustc_interface[c7c8f488c1d96c6d]::interface::run_compiler<core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>, rustc_driver_impl[a7afd08560397dfd]::run_compiler::{closure#0}>::{closure#0}, core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>>::{closure#0}, core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>>
  26:     0x7fc514da7389 - <<std[b17d18de645d14f5]::thread::Builder>::spawn_unchecked_<rustc_interface[c7c8f488c1d96c6d]::util::run_in_thread_with_globals<rustc_interface[c7c8f488c1d96c6d]::util::run_in_thread_pool_with_globals<rustc_interface[c7c8f488c1d96c6d]::interface::run_compiler<core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>, rustc_driver_impl[a7afd08560397dfd]::run_compiler::{closure#0}>::{closure#0}, core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>>::{closure#0}, core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e20c1d627f8cf941]::result::Result<(), rustc_span[5a19da4d0aee85d6]::ErrorGuaranteed>>::{closure#1} as core[e20c1d627f8cf941]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7fc510398675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h89edab1f30a12557
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/alloc/src/boxed.rs:2015:9
  28:     0x7fc510398675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbdac67f72b3ccfae
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/alloc/src/boxed.rs:2015:9
  29:     0x7fc510398675 - std::sys::pal::unix::thread::Thread::new::thread_start::h1707b2f687d14d64
                               at /rustc/cb4d9a1902b3ea17e93872dafb76d24aa6295c47/library/std/src/sys/pal/unix/thread.rs:108:17
  30:     0x7fc5101839eb - <unknown>
  31:     0x7fc5102077cc - <unknown>
  32:                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.77.0-nightly (cb4d9a190 2024-01-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z codegen-backend=cranelift -Z crate-attr=feature(linkage) -Z dump-mir-dir=dir

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


@bjorn3
Copy link
Member

bjorn3 commented Jan 31, 2024

Duplicate of #1243

@bjorn3 bjorn3 marked this as a duplicate of #1243 Jan 31, 2024
@bjorn3 bjorn3 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2024
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