{"id":"06d2b41489337d32","repo":"rust-lang/rust","slug":"non-empty-waiters-vec","errorCode":null,"errorMessage":"non-empty waiters vec","messagePattern":"non-empty waiters vec","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_middle/src/query/job.rs","lineNumber":127,"sourceCode":"        }\n    }\n\n    /// Sets the latch and resumes all waiters on it\n    fn set(&self) {\n        let mut waiters_guard = self.waiters.lock();\n        let waiters = waiters_guard.take().unwrap(); // mark the latch as complete\n        let registry = rustc_thread_pool::Registry::current();\n        for waiter in waiters {\n            rustc_thread_pool::mark_unblocked(&registry);\n            waiter.condvar.notify_one();\n        }\n    }\n\n    /// Removes a single waiter from the list of waiters.\n    /// This is used to break query cycles.\n    pub fn extract_waiter(&self, waiter: usize) -> Arc<QueryWaiter<'tcx>> {\n        let mut waiters_guard = self.waiters.lock();\n        let waiters = waiters_guard.as_mut().expect(\"non-empty waiters vec\");\n        // Remove the waiter from the list of waiters\n        waiters.remove(waiter)\n    }\n}\n","sourceCodeStart":109,"sourceCodeEnd":132,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_middle/src/query/job.rs#L109-L132","documentation":"`QueryLatch::extract_waiter` (job.rs:127) calls `.expect(\"non-empty waiters vec\")` on `self.waiters` while breaking a query cycle. The waiter vector is only `take`n (emptied) when the latch is fully set; calling `extract_waiter` on an already-resolved latch violates the cycle-breaker's precondition. It is an invariant of the query deadlock detector, not a user-facing check.","triggerScenarios":"Reached only inside the rustc query system's cycle handler: when the deadlock detector decides to remove one specific waiter from a latch to break a cycle, but that latch's `waiters` field has already been `take`n—meaning another thread concurrently completed the query and drained the list. Indicates a race between latch completion and cycle extraction.","commonSituations":"Observed by rustc developers stress-testing parallel query evaluation (`-Z threads=N` with pathological dependency graphs), running the compiler under heavy load with very deep generic recursion, or testing nightly query-system changes. End-user Rust code cannot deliberately construct it; ordinary crashes here are rustc bugs.","solutions":["Report to rust-lang/rust with `rustc -vV`, thread count, and a minimal reproducer (this is a race in the query system).","Retry with a single thread: `RUST_MIN_STACK=... rustc -Z threads=1` or set `RUSTC_THREADS=1` via cargo to sidestep the race.","Retry on the latest nightly; query-system races get fixed quickly.","If building rustc itself, re-run `x.py build` after `cargo clean` to rule out a stale incremental interaction with the query scheduler."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// 'non-empty waiters vec' is an internal query-system invariant violation (ICE).\n// Nothing in user code triggers it deterministically; treat as transient.\nuse std::process::Command;\nfn compile_with_jitter(dir: &str) -> bool {\n    for attempt in 0..3u8 {\n        // Single-threaded rebuild avoids the concurrency edge case in the query scheduler.\n        let ok = Command::new(\"cargo\")\n            .args([\"build\", \"-j\", \"1\"])\n            .current_dir(dir)\n            .status()\n            .map(|s| s.success())\n            .unwrap_or(false);\n        if ok { return true; }\n        let _ = Command::new(\"cargo\").args([\"clean\"]).current_dir(dir).status();\n    }\n    false\n}","preventionTips":["Avoid running multiple `rustc`/`cargo` invocations against the same target dir simultaneously.","Use `-j 1` to reproduce/avoid scheduler races in the query system.","Bump the toolchain: query-system bugs are fixed frequently in nightly.","Report with `RUST_BACKTRACE=full`; this is a compiler invariant, not application logic."],"tags":["rustc","query-system","deadlock","race-condition","internal-compiler-error"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}