From 5e0f7db62955df83ad87f026788f571617b82ef9 Mon Sep 17 00:00:00 2001 From: tignear Date: Tue, 20 Oct 2026 22:55:11 +0900 Subject: [PATCH] fix(runtime): recheck abort after parallel dependency waits A dependent task could observe a failed producer's progress and leave its wait loop without observing the abort flag. This intermittently ran work after a failed dependency and caused the merge queue checks for #1599 to fail. Reload abort with acquire ordering before executing a task, after acquiring its dependencies' progress. Extend the failure/recovery regression to 2,000 epochs each with zero and default idle spin, preserving the assertions that dependents never execute and the pool remains reusable. Validation: - Reproduced the original failure locally on iteration 303 before the fix. - cargo test --locked -p celox-runtime --lib: 42 passed. - cargo test --locked -p celox --test comb_observer --test runtime_api --test flip_flop: 2,022 passed, 44 existing ignores; includes native and Cranelift parallel variants. - cargo fmt --all -- --check - cargo clippy --locked -p celox-runtime --all-targets -- -D warnings - git diff --check Change-Id: I7f373d7051fe16a8fc59ba4a4e41e366d04988c7 --- crates/celox-runtime/src/parallel.rs | 37 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/crates/celox-runtime/src/parallel.rs b/crates/celox-runtime/src/parallel.rs index fe2e149e72b..4ad73c09237 100644 --- a/crates/celox-runtime/src/parallel.rs +++ b/crates/celox-runtime/src/parallel.rs @@ -266,7 +266,10 @@ impl Shared { timing.waits.push((other, completed, start, trace.nanos())); } } - if !aborted { + // A failed producer publishes its abort before its progress. The + // acquire above may satisfy the wait without entering the loop, + // so reload abort after observing that progress. + if !aborted && !self.abort.0.load(Ordering::Acquire) { if let (Some(trace), Some(timing)) = (trace, &mut timing) { timing.start = trace.nanos(); } @@ -640,19 +643,25 @@ mod tests { #[test] fn failures_skip_pending_work_and_report_the_first_task() { let (schedule, predecessors) = chain_schedule(); - let mut pool = LanePool::new(3).unwrap(); - let runner = recorder(predecessors.clone(), Some(0)); - assert_eq!( - pool.run(&schedule, &runner), - Err(LaneTaskFailure { task: 0, code: 7 }) - ); - // Dependents of the failed task never ran. - assert!(!runner.done[1].load(Ordering::Acquire)); - assert!(!runner.done[3].load(Ordering::Acquire)); - // The pool remains usable after a failure. - let runner = recorder(predecessors, None); - pool.run(&schedule, &runner).unwrap(); - assert_eq!(runner.calls.load(Ordering::Relaxed), 4); + for idle_spin in [Duration::ZERO, LanePool::DEFAULT_IDLE_SPIN] { + let mut pool = LanePool::with_idle_spin(3, idle_spin).unwrap(); + // Exercise both parked and spinning workers across failure/recovery + // epochs: a dependent can observe progress just as abort is set. + for _ in 0..2000 { + let runner = recorder(predecessors.clone(), Some(0)); + assert_eq!( + pool.run(&schedule, &runner), + Err(LaneTaskFailure { task: 0, code: 7 }) + ); + // Dependents of the failed task never ran. + assert!(!runner.done[1].load(Ordering::Acquire)); + assert!(!runner.done[3].load(Ordering::Acquire)); + // The pool remains usable after a failure. + let runner = recorder(predecessors.clone(), None); + pool.run(&schedule, &runner).unwrap(); + assert_eq!(runner.calls.load(Ordering::Relaxed), 4); + } + } } #[test]