Skip to content

Compiler panic when using recursive enums #136814

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

Closed
eternalfrustation opened this issue Feb 10, 2025 · 2 comments
Closed

Compiler panic when using recursive enums #136814

eternalfrustation opened this issue Feb 10, 2025 · 2 comments
Labels
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.

Comments

@eternalfrustation
Copy link

Apparently, using enums which recursively reference themselves will result in a compiler panic

Below is a minimal enum that demonstrates this

Code

#[derive(Debug, Clone)]
pub enum DocAST {
    Line(DocAST),
    Text(String),
    Multi(Vec<DocAST>),
}

Meta

rustc --version --verbose:

rustc 1.85.0-nightly (d117b7f21 2024-12-31)
binary: rustc
commit-hash: d117b7f211835282b3b177dc64245fff0327c04c
commit-date: 2024-12-31
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

Error output

thread 'rustc query cycle handler' panicked at compiler/rustc_query_system/src/query/job.rs:504:9:
deadlock detected as we're unable to find a query cycle to break
current query map:
{"reason":"compiler-message","package_id":"path+file:///myprojects/rascii#0.1.0","manifest_path":"/myprojects/rascii/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"rascii","src_path":"/myprojects/rascii/src/main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"message":{}}
stack backtrace:
   0:     0x7ff77bad056a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3bfd73294bb40f7b
   1:     0x7ff77c213426 - core::fmt::write::hdcaca49087f51fc7
   2:     0x7ff77d13bcd1 - std::io::Write::write_fmt::h111e1637c3334990
   3:     0x7ff77bad03c2 - std::sys::backtrace::BacktraceLock::print::hc3646ef95a493c1e
   4:     0x7ff77bad28c9 - std::panicking::default_hook::{{closure}}::h4b5403c3b4e26604
   5:     0x7ff77bad2712 - std::panicking::default_hook::ha8ce32ac4bb77893
   6:     0x7ff77ac3dac8 - std[b0d549a58380ee12]::panicking::update_hook::<alloc[3e6ca5e693a94b55]::boxed::Box<rustc_driver_impl[3d9a82418e2383aa]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7ff77bad3083 - std::panicking::rust_panic_with_hook::h8585f3a7d0c05184
   8:     0x7ff77bad2d7a - std::panicking::begin_panic_handler::{{closure}}::h4ba34aed5dca5a84
   9:     0x7ff77bad0a19 - std::sys::backtrace::__rust_end_short_backtrace::h85d965d23ad807f9
  10:     0x7ff77bad2a3d - rust_begin_unwind
  11:     0x7ff77879df90 - core::panicking::panic_fmt::he33b64161001a34b
  12:     0x7ff77b67c37a - rustc_query_system[89d8cdfdd921bf80]::query::job::break_query_cycles
  13:     0x7ff77ac3438c - std[b0d549a58380ee12]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5daad5fca9910f79]::util::run_in_thread_pool_with_globals<rustc_interface[5daad5fca9910f79]::interface::run_compiler<(), rustc_driver_impl[3d9a82418e2383aa]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#2}::{closure#1}, ()>
  14:     0x7ff77ac42b84 - <<std[b0d549a58380ee12]::thread::Builder>::spawn_unchecked_<rustc_interface[5daad5fca9910f79]::util::run_in_thread_pool_with_globals<rustc_interface[5daad5fca9910f79]::interface::run_compiler<(), rustc_driver_impl[3d9a82418e2383aa]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#2}::{closure#1}, ()>::{closure#1} as core[d51f785d25e19ba0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  15:     0x7ff77d10f2c1 - std::sys::pal::unix::thread::Thread::new::thread_start::h9639e0dd1625826a
  16:     0x7ff7774b7f58 - <unknown>
  17:     0x7ff77752a5cc - <unknown>
  18:                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: please make sure that you have updated to the latest nightly

note: please attach the file at `/myprojects/rascii/rustc-ice-2025-02-10T11_25_26-27322.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C target-cpu=native -C link-arg=-fuse-ld=lld -Z threads=8

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

query stack during panic:
end of query stack
query cycle handler thread panicked, aborting process
sccache: Compile terminated by signal 6
error: could not compile `rascii` (bin "rascii")

Caused by:
  process didn't exit successfully: `sccache /home/sandy/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name rascii --edition=2024 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=119 --crate-type bin --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=782e36cd0d04c0c9 -C extra-filename=-8509920159b569fe --out-dir /myprojects/rascii/target/debug/deps -C incremental=/myprojects/rascii/target/debug/incremental -L dependency=/myprojects/rascii/target/debug/deps -C target-cpu=native -C link-arg=-fuse-ld=lld -Z threads=8` (exit status: 2)
Backtrace

thread 'rustc query cycle handler' panicked at compiler/rustc_query_system/src/query/job.rs:504:9:
deadlock detected as we're unable to find a query cycle to break
current query map:
{"reason":"compiler-message","package_id":"path+file:///myprojects/rascii#0.1.0","manifest_path":"/myprojects/rascii/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"rascii","src_path":"/myprojects/rascii/src/main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"message":{}}
stack backtrace:
   0:     0x7f45234d056a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3bfd73294bb40f7b
   1:     0x7f4523c13426 - core::fmt::write::hdcaca49087f51fc7
   2:     0x7f4524b3bcd1 - std::io::Write::write_fmt::h111e1637c3334990
   3:     0x7f45234d03c2 - std::sys::backtrace::BacktraceLock::print::hc3646ef95a493c1e
   4:     0x7f45234d28c9 - std::panicking::default_hook::{{closure}}::h4b5403c3b4e26604
   5:     0x7f45234d2712 - std::panicking::default_hook::ha8ce32ac4bb77893
   6:     0x7f452263dac8 - std[b0d549a58380ee12]::panicking::update_hook::<alloc[3e6ca5e693a94b55]::boxed::Box<rustc_driver_impl[3d9a82418e2383aa]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f45234d3083 - std::panicking::rust_panic_with_hook::h8585f3a7d0c05184
   8:     0x7f45234d2d7a - std::panicking::begin_panic_handler::{{closure}}::h4ba34aed5dca5a84
   9:     0x7f45234d0a19 - std::sys::backtrace::__rust_end_short_backtrace::h85d965d23ad807f9
  10:     0x7f45234d2a3d - rust_begin_unwind
  11:     0x7f452019df90 - core::panicking::panic_fmt::he33b64161001a34b
  12:     0x7f452307c37a - rustc_query_system[89d8cdfdd921bf80]::query::job::break_query_cycles
  13:     0x7f452263438c - std[b0d549a58380ee12]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5daad5fca9910f79]::util::run_in_thread_pool_with_globals<rustc_interface[5daad5fca9910f79]::interface::run_compiler<(), rustc_driver_impl[3d9a82418e2383aa]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#2}::{closure#1}, ()>
  14:     0x7f4522642b84 - <<std[b0d549a58380ee12]::thread::Builder>::spawn_unchecked_<rustc_interface[5daad5fca9910f79]::util::run_in_thread_pool_with_globals<rustc_interface[5daad5fca9910f79]::interface::run_compiler<(), rustc_driver_impl[3d9a82418e2383aa]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#2}::{closure#1}, ()>::{closure#1} as core[d51f785d25e19ba0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  15:     0x7f4524b0f2c1 - std::sys::pal::unix::thread::Thread::new::thread_start::h9639e0dd1625826a
  16:     0x7f451eeb7f58 - <unknown>
  17:     0x7f451ef2a5cc - <unknown>
  18:                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: please make sure that you have updated to the latest nightly

note: please attach the file at `/myprojects/rascii/rustc-ice-2025-02-10T11_27_43-27753.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C target-cpu=native -C link-arg=-fuse-ld=lld -Z threads=8

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

query stack during panic:
end of query stack
query cycle handler thread panicked, aborting process
sccache: Compile terminated by signal 6
error: could not compile `rascii` (bin "rascii")

Caused by:
  process didn't exit successfully: `sccache /home/sandy/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name rascii --edition=2024 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=119 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=8e36858a67266172 -C extra-filename=-3e25946fc2c85d6b --out-dir /myprojects/rascii/target/debug/deps -C incremental=/myprojects/rascii/target/debug/incremental -L dependency=/myprojects/rascii/target/debug/deps -C target-cpu=native -C link-arg=-fuse-ld=lld -Z threads=8` (exit status: 2)


rustc-ice-2025-02-10T11_27_43-27753.txt

@eternalfrustation eternalfrustation 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 Feb 10, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 10, 2025
@theemathas
Copy link
Contributor

theemathas commented Feb 10, 2025

Seems similar to #136453

Updating your rust should fix this

@fee1-dead
Copy link
Member

Please update your Rust version and report again if the issue persists. I am unable to reproduce this on the playground.

@fee1-dead fee1-dead closed this as not planned Won't fix, can't repro, duplicate, stale Feb 10, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 10, 2025
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants