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

rustc query cycle handler panic #136453

Closed
fe3dback opened this issue Feb 2, 2025 · 7 comments
Closed

rustc query cycle handler panic #136453

fe3dback opened this issue Feb 2, 2025 · 7 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-needs-info Status: The issue lacks details necessary to triage or act on it. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-parallel Working group: Parallelizing the compiler

Comments

@fe3dback
Copy link

fe3dback commented Feb 2, 2025

It is an invalid data structure (because it is recursive), and the complier can't know size on compile time.
But compiler panic is unexpected here.

Code

use brg_core::prelude::{Chunk, V2};

#[derive(Default, Copy, Clone)]
pub struct LodQuadTree {
    pos:   V2,
    size:  V2,
    len:   u32,
    child: Option<[LodQuadTree; 4]>, // problem on this line (recursive)
}

Meta

rustc --version --verbose:

rustc 1.86.0-nightly (f85c6de55 2025-01-26)
binary: rustc
commit-hash: f85c6de55206dbee5ffedfd821df1503a7b92346
commit-date: 2025-01-26
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Error output

thread 'rustc query cycle handler' panicked at compiler/rustc_query_system/src/query/job.rs:502:9:
deadlock detected as we're unable to find a query cycle to break
current query map:
{}
stack backtrace:
   0:     0x7adb02bb1625 - std::backtrace::Backtrace::create::h016cd0347bc39098
   1:     0x7adb00f8e6f5 - std::backtrace::Backtrace::force_capture::h90cd71109775fcb3
   2:     0x7adb0015b864 - std[cc940dec3ff43b12]::panicking::update_hook::<alloc[5f7a888829935c2b]::boxed::Box<rustc_driver_impl[af2bdb3744899392]::install_ice_hook::{closure#1}>>::{closure#0}
   3:     0x7adb00fa7073 - std::panicking::rust_panic_with_hook::hbfeeff1ab3569ba1
   4:     0x7adb00fa6d6a - std::panicking::begin_panic_handler::{{closure}}::h32c93c4f5d28ab99
   5:     0x7adb00fa46e9 - std::sys::backtrace::__rust_end_short_backtrace::h1884c239824d44f7
   6:     0x7adb00fa6a2d - rust_begin_unwind
   7:     0x7adafdc39bd0 - core::panicking::panic_fmt::he58927c3c03479ba
   8:     0x7adb00b9dcba - rustc_query_system[b5c6449b7ccd2566]::query::job::break_query_cycles
   9:     0x7adb001517dc - std[cc940dec3ff43b12]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_pool_with_globals<rustc_interface[d0d5d02e7a56d74f]::interface::run_compiler<(), rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#2}::{closure#1}, ()>
  10:     0x7adb00162e98 - <<std[cc940dec3ff43b12]::thread::Builder>::spawn_unchecked_<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_pool_with_globals<rustc_interface[d0d5d02e7a56d74f]::interface::run_compiler<(), rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#2}::{closure#1}, ()>::{closure#1} as core[c1de5c9ad145c0db]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  11:     0x7adb0266832b - std::sys::pal::unix::thread::Thread::new::thread_start::hb22e947f5885a296
  12:     0x7adafc69ca94 - start_thread
                               at ./nptl/pthread_create.c:447:8
  13:     0x7adafc729c3c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  14:                0x0 - <unknown>


rustc version: 1.86.0-nightly (f85c6de55 2025-01-26)
platform: x86_64-unknown-linux-gnu
@fe3dback fe3dback 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 2, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 2, 2025
@compiler-errors
Copy link
Member

Can you share more information about how you're invoking the Rust compiler? Are you passing any -Z flags perhaps?

@matthiaskrgr matthiaskrgr added the WG-compiler-parallel Working group: Parallelizing the compiler label Feb 3, 2025
@jieyouxu jieyouxu added the S-needs-info Status: The issue lacks details necessary to triage or act on it. label Feb 3, 2025
@fe3dback
Copy link
Author

fe3dback commented Feb 3, 2025

yes, forgot to write about custom config

.cargo/config.toml

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
    "-C",
    # fast unstable linker
    "link-arg=-fuse-ld=mold",
    # (Nightly) Make the current crate share its generic instantiations
    "-Zshare-generics=y",
    "-Zthreads=0",
]

[unstable]
codegen-backend = true

[profile.dev]
codegen-backend = "cranelift"

[profile.dev.package."*"]
codegen-backend = "llvm"

@lqd
Copy link
Member

lqd commented Feb 3, 2025

Does reproducing this require code from brg_core?

@fe3dback
Copy link
Author

fe3dback commented Feb 3, 2025

no, it is reproduced in minimum main.rs:

pub struct LodQuadTree {
    child: Option<[LodQuadTree; 4]>, // problem on this line (recursive)
}

fn main() {
    println!("hello world")
}

Image

@lqd
Copy link
Member

lqd commented Feb 3, 2025

I personally can't reproduce this.

Aaaaaaaaaaaaaaaaaaaaaaaaaaaaah I know what this is. It's the driver queries with -Zthreads>1.

@lqd
Copy link
Member

lqd commented Feb 3, 2025

Summary: this is fixed on nightly.

Whenever you're using nightly, the error messages mention to update and check again, for that very reason.

note: please make sure that you have updated to the latest nightly

This is a duplicate of #135870 and was already fixed by #135988. I've verified that updating your toolchain to at least nightly-2025-01-28 should prevent this issue from appearing in your project. Feel free to reopen if it happens again.

Thanks for opening an issue!

@lqd lqd closed this as completed Feb 3, 2025
@fe3dback
Copy link
Author

fe3dback commented Feb 3, 2025

confirm, after update to latest nightly, I get correct error message error[E0072]: recursive type LodQuadTree has infinite size, and compiler no longer panics.

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 3, 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) ❄️ S-needs-info Status: The issue lacks details necessary to triage or act on it. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-parallel Working group: Parallelizing the compiler
Projects
None yet
Development

No branches or pull requests

6 participants