From d122da6ae3bb01419d2c1fb21cc92ddf55cdd5a2 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 11:47:36 -0800 Subject: [PATCH] Tests: the killed-helper test's threads drop their device clones before they answer a_helper_killed_mid_make_leaves_every_make_its_refusal_at_once makes each pipeline, and the stage fill, on a detached thread holding a clone of the device, and that thread sent its answer before its clone was dropped. After the last answer the test drops its own device and returns, so a detached thread could hold the last reference and destroy the device while the process exits. Each thread now drops its clone before it answers, so the test's own drop is the device's last. Test-only: no product file changes. Seen once: the pin round's runtime item on a Radeon RX 7900 XTX (RADV NAVI31), job m3-max-79526, at 685df4244e: the test printed its two lines and "test result: ok", then the process ended with SIGSEGV. The same item passed this test on the Iris Xe, the Radeon 780M, Hawk Point, the RX 550, the RTX 2080 and the RTX 5080 Laptop. --- crates/metal2vulkan-runtime/src/tests/stage.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan-runtime/src/tests/stage.rs b/crates/metal2vulkan-runtime/src/tests/stage.rs index 16cd9e400..145b0fcab 100644 --- a/crates/metal2vulkan-runtime/src/tests/stage.rs +++ b/crates/metal2vulkan-runtime/src/tests/stage.rs @@ -910,6 +910,9 @@ mod on_device { let made = (device .new_compute_pipeline_state(&descriptor, crate::tests::no_constexpr_samplers)) .err(); + // The clone goes before the answer, so the caller's drop is the device's last and + // no thread of the test destroys it while the process exits. + drop(device); let _ = answer.send(made); }); answered @@ -940,7 +943,10 @@ mod on_device { let (filled, fill) = mpsc::channel(); let (filler, asked) = (device.clone(), request.clone()); std::thread::spawn(move || { - let _ = filled.send(filler.fill_stage(&asked, to_helper, from_helper)); + let fill = filler.fill_stage(&asked, to_helper, from_helper); + // As in `bounded`: the clone goes before the answer. + drop(filler); + let _ = filled.send(fill); }); let filled = fill.recv_timeout(PATIENCE); let filled = filled.unwrap_or_else(|_| panic!("{name}: the fill never ended"));