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

Compiler crash in 1.76.0-beta.1 #119463

Closed
mumbleskates opened this issue Dec 31, 2023 · 8 comments · Fixed by #119553
Closed

Compiler crash in 1.76.0-beta.1 #119463

mumbleskates opened this issue Dec 31, 2023 · 8 comments · Fixed by #119553
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@mumbleskates
Copy link
Contributor

mumbleskates commented Dec 31, 2023

Code

A minimal example is slightly involved; the minimal triggering case seems to be that a proc-macro produces code that attempts to impl a trait that isn't visible from the location it ends up.

edit: this turns out not to require macros at all.

Cargo.toml

[package]
name = "bugreport"
edition = "2021"

src/lib.rs

trait PrivateTrait {
    /// Without this associated const, there is no crash.
    const FOO: usize;
}

src/main.rs

struct LocalType;

/// This should complain that PrivateTrait is not visible. Instead, the compiler panics.
impl bugreport::PrivateTrait for LocalType {
    /// Without actually defining the trait's associated const, there is no crash.
    const FOO: usize = 1;
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.76.0-beta.1 (0e09125c6 2023-12-21)
binary: rustc
commit-hash: 0e09125c6c3c2fd70d7de961bcf0e51575235fad
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.76.0-beta.1
LLVM version: 17.0.6

This also occurs in nightly (rustc 1.77.0-nightly (fb5ed726f 2023-12-28)), but not in stable (which provides the correct complaint that PrivateTrait is not publicly re-exported)

Error output

thread 'rustc' panicked at compiler/rustc_middle/src/ty/mod.rs:432:29:
DefId::expect_local: `DefId(20:0 ~ bugreport[22e0])` isn't local
Backtrace

stack backtrace:
   0:     0x7f6adfe306f6 - std::backtrace_rs::backtrace::libunwind::trace::h261606ad26a499c1
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f6adfe306f6 - std::backtrace_rs::backtrace::trace_unsynchronized::hd183f0625477fb28
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f6adfe306f6 - std::sys_common::backtrace::_print_fmt::hd7f8fef21b4eda67
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f6adfe306f6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h623d9b51f2f453f1
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f6adfe82f40 - core::fmt::rt::Argument::fmt::h9f417ac76a86f368
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/rt.rs:142:9
   5:     0x7f6adfe82f40 - core::fmt::write::hc9b6faf4ac2aeff7
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f6adfe2453f - std::io::Write::write_fmt::hfead1eee52c2e65e
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/io/mod.rs:1810:15
   7:     0x7f6adfe304d4 - std::sys_common::backtrace::_print::hd5d66399c7df88a2
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f6adfe304d4 - std::sys_common::backtrace::print::he81ed2da642d37e5
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f6adfe33267 - std::panicking::default_hook::{{closure}}::h85773f4fa117163d
  10:     0x7f6adfe32fc9 - std::panicking::default_hook::h6a1694a91d09b278
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:292:9
  11:     0x7f6adce189cc - std[ee6a4c5be0dc2fe4]::panicking::update_hook::<alloc[ca44ae591fa90b46]::boxed::Box<rustc_driver_impl[9db4319ac0e53fa6]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f6adfe339b6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcb3fe3b9bb537ba8
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/alloc/src/boxed.rs:2029:9
  13:     0x7f6adfe339b6 - std::panicking::rust_panic_with_hook::h0a7ad96e90f7145b
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:783:13
  14:     0x7f6adfe33702 - std::panicking::begin_panic_handler::{{closure}}::h7919090525c6485e
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:657:13
  15:     0x7f6adfe30bf6 - std::sys_common::backtrace::__rust_end_short_backtrace::hf3289479464f7dfe
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f6adfe33460 - rust_begin_unwind
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:645:5
  17:     0x7f6adfe7f645 - core::panicking::panic_fmt::hcc9f77c5c132af55
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/panicking.rs:72:14
  18:     0x7f6adec784d3 - <rustc_resolve[affe76dba0cece58]::late::LateResolutionVisitor as rustc_ast[4aa1586181236210]::visit::Visitor>::visit_item
  19:     0x7f6adee2d7ff - <rustc_resolve[affe76dba0cece58]::Resolver>::resolve_crate::{closure#0}
  20:     0x7f6adee2ad1a - <rustc_resolve[affe76dba0cece58]::Resolver>::resolve_crate
  21:     0x7f6adeeb6d72 - rustc_interface[510b71011450ca5b]::passes::resolver_for_lowering
  22:     0x7f6adeeb5e2b - rustc_query_impl[b697241ad8aeb7f0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b697241ad8aeb7f0]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[feea9eb5351a5817]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7f6adef1f8ec - rustc_query_system[f4aa0f8944b24174]::query::plumbing::try_execute_query::<rustc_query_impl[b697241ad8aeb7f0]::DynamicConfig<rustc_query_system[f4aa0f8944b24174]::query::caches::SingleCache<rustc_middle[feea9eb5351a5817]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[b697241ad8aeb7f0]::plumbing::QueryCtxt, true>
  24:     0x7f6adef1eff3 - rustc_query_impl[b697241ad8aeb7f0]::query_impl::resolver_for_lowering::get_query_incr::__rust_end_short_backtrace
  25:     0x7f6aded0bab3 - rustc_interface[510b71011450ca5b]::interface::run_compiler::<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0}
  26:     0x7f6adee3b25b - std[ee6a4c5be0dc2fe4]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[510b71011450ca5b]::util::run_in_thread_with_globals<rustc_interface[510b71011450ca5b]::interface::run_compiler<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>
  27:     0x7f6adee3b0b9 - <<std[ee6a4c5be0dc2fe4]::thread::Builder>::spawn_unchecked_<rustc_interface[510b71011450ca5b]::util::run_in_thread_with_globals<rustc_interface[510b71011450ca5b]::interface::run_compiler<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#1} as core[9c77087b21480946]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7f6adfe3d8e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d7c8f150ab9c84c
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/alloc/src/boxed.rs:2015:9
  29:     0x7f6adfe3d8e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h570d5b005c242c15
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/alloc/src/boxed.rs:2015:9
  30:     0x7f6adfe3d8e5 - std::sys::unix::thread::Thread::new::thread_start::h36b0a20c0b2361ad
                               at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys/unix/thread.rs:108:17
  31:     0x7f6ad9e97ada - <unknown>
  32:     0x7f6ad9f2847c - <unknown>
  33:                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.76.0-beta.1 (0e09125c6 2023-12-21) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack

@mumbleskates mumbleskates 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 31, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 31, 2023
@saethlin saethlin added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Dec 31, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 31, 2023
@saethlin saethlin added I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 31, 2023
@Jules-Bertholet
Copy link
Contributor

searched nightlies: from nightly-2023-11-11 to nightly-2023-12-28
regressed nightly: nightly-2023-12-19
searched commit range: 6a62871...3f28fe1
regressed commit: 321b656

bisected with cargo-bisect-rustc v0.6.7

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 1.75.0 --end 2023-12-28 --regress ice 

#118657 @petrochenkov

@Apetree100122
Copy link

0x7f6adfe7f645 - core::panicking::panic_
fmt::hcc 9f77c5c132af55 at /rustc/0e09125c6c3c2fd70d7de961bcf
0e51575235fad/library/core /src/panicking.rs:
72:14 180 x
7f6adec784d3 - <rustc
_resolve[affe76dba0cece58]::late
::LateResolutionVisitor as rustc_ast[4aa1586181236210]::visit::Visitor>::visit_item 19: 0x7f6adee2d7ff - <rustc_resolve[affe76dba0cece58]::Resolver>::resolve_crate
::{closure#0} 20: 0x7f6adee2ad1a - <rustc_resolve[affe76dba0cece58]::Resolver>::resolve_crate 21: 0x7f6adeeb6d72 - rustc_interface[510b71011450ca5b]::passes::resolver_for_lowering 22: 0x7f6adeeb5e2b - rustc_query_impl[b697241ad8aeb7f0]::plumbing::_rust_begin_short_backtrace::<rustc_query_impl[b697241ad8aeb7f0]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[feea9eb5351a5817]::query::erase::Erased<[u8; 8usize]>>
23: 0x7f6adef1f8ec - rustc_query_system[f4aa0f8944b24174]:
:query::plumbing::try_execute_query::<rustc_query

impl[b697241ad8aeb7f0]::DynamicConfig<rustc_query_system[f4aa0f8944b24174]::query::caches::SingleCache<rustc_middle[feea9eb5351a5817]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[b697241ad8aeb7f0]::plumbing::QueryCtxt, true> 24: 0x7f6adef1eff3 - rustc_query_impl[b697241ad8aeb7f0]::query_impl::resolver_for_lowering::get_query_incr::__rust_end_short_backtrace 25: 0x7f6aded0bab3 - rustc_interface[510b71011450ca5b]::interface::run_compiler::<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0} 26: 0x7f6adee3b25b - std[ee6a4c5be0dc2fe4]::sys_common::backtrace::_rust_begin_short_backtrace::<rustc_interface[510b71011450ca5b]::util::run_in_thread_with_globals<rustc_interface[510b71011450ca5b]::interface::run_compiler<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>27: 0x7f6adee3b0b9 - <<std[ee6a4c5be0dc2fe4]::thread::Builder>::spawn_unchecked<rustc_interface[510b71011450ca5b]::util::run_in_thread_with_globals<rustc_interface[510b71011450ca5b]::interface::run_compiler<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#1} as core[9c77087b21480946]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 28: 0x7f6adfe3d8e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce>::call_once::h5d7c8f150ab9c84c at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/alloc/src/boxed.rs:2015:9 29: 0x7f6adfe3d8e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce>::call_once::h570d5b005c242c15 at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/alloc/src/boxed.rs:2015:9 30: 0x7f6adfe3d8e5 - std::sys::unix::thread::Thread::new::thread_start::h36b0a20c0b2361ad at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys/unix/thread.rs:108:17 31: 0x7f6ad9e97ada - 32: 0x7f6ad9f2847c - 33: 0x0 -
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.76.0-beta.1 (0e09125 2023-12-21) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack

@Apetree100122
Copy link

That is line 18 to 33

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 31, 2023
@bvanjoi
Copy link
Contributor

bvanjoi commented Jan 3, 2024

An interesting issue, @rustbot claim

@mumbleskates
Copy link
Contributor Author

interesting that the crash also doesn't happen if we qualify the trait with crate:: instead of the crate's name.

@bvanjoi
Copy link
Contributor

bvanjoi commented Jan 4, 2024

the crash also doesn't happen if we qualify the trait with crate:: instead of the crate's name.

The crate_name:xxx is interpreted as referring to an external crate, whereas crate:xxx not

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 4, 2024
stop feed vis when cant access for trait item

Fixes rust-lang#119463

It's not necessary to feed visibility when use a private trait.

r? `@petrochenkov`
@bors bors closed this as completed in ee882d6 Jan 4, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 4, 2024
Rollup merge of rust-lang#119553 - bvanjoi:fix-119463, r=petrochenkov

stop feed vis when cant access for trait item

Fixes rust-lang#119463

It's not necessary to feed visibility when use a private trait.

r? ``@petrochenkov``
@mumbleskates
Copy link
Contributor Author

The crate_name:xxx is interpreted as referring to an external crate, whereas crate:xxx not

right; i'm assuming it hits a different resolver codepath, despite both working the same if the referred ident is public.

thanks for the quick fix!

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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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.

7 participants