Files
metal2vulkan/crates
Anees Iqbal 0e2ac3f345 exit_guard: the test-only step between the counts tolerates destroyed thread-locals
In builds of the runtime's own tests, Guard::close's wait runs a test
step between its reads (between_counts), which read BETWEEN_COUNTS with
LocalKey::with. On macOS exit() destroys the exiting thread's
thread-locals before it runs the exit handlers, so a test child that
exited from a thread that had used the step's thread-local, with a
section of the runtime's in progress on another thread, panicked in the
hook ("cannot access a Thread Local Storage value during or after
destruction"), and the panic in exit_handler, which cannot unwind,
aborted the child. Measured on the M3 (MoltenVK 1.4.2): 2965 of 5931
probe children aborted there, every one that exited with a command
buffer in flight, none of those that did not. Builds without cfg(test)
run no step (between_counts is empty), so consumers never reached it.

The step now reads its thread-local with try_with and runs nothing once
it is destroyed. The new test runs the hook's wait in a thread-local's
destructor after the step's thread-local was destroyed: it aborted the
test process before, and now the wait ends at its bound.

(cherry picked from commit 10f0048c43fc0498c61842bd823fdae1dd632c09)
2026-11-08 19:10:52 -08:00
..