From 608887892d91bdc0aa070728579ad98c96d0add7 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Sat, 17 Oct 2026 11:15:26 +0200 Subject: [PATCH] Skip the GC test for completion locks on macOS with Julia 1.14 Since JuliaLang/julia#61341, the macOS exception handler that parks a thread at a GC safepoint identifies the faulting thread by its pthread id, without skipping threads that have exited. A foreign thread that reuses the id of one that exited is then matched to the dead entry and resumed instead of parked, so the collector waits for it forever (JuliaLang/julia#63893). The test that collects while a driver thread waits for a completion's lock triggers exactly that: an earlier test's foreign thread has exited, and the new one spins on the lock, hitting safepoints while `GC.gc()` runs. This made the macOS nightly job hang until it was cancelled. Skip that test on affected versions until the runtime is fixed. --- test/synchronization.jl | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/test/synchronization.jl b/test/synchronization.jl index 3bf8b9b..1851bd6 100644 --- a/test/synchronization.jl +++ b/test/synchronization.jl @@ -419,15 +419,25 @@ end @test timedwait(() -> @atomic(call.done), 30) === :ok @test !@atomic(call.failed) - # a driver thread waiting for the lock lets the garbage collector run - c = GPUToolbox.Completion() - @atomic c.state = GPUToolbox.PENDING - GC.@preserve c begin - lock(c.cond) - signal_later(pointer_from_objref(c), 0) - @gcsafe_ccall uv_sleep(10::Cuint)::Cvoid - GC.gc() - unlock(c.cond) - @test timedwait(() -> (@atomic c.state) == GPUToolbox.RELEASED, 30) === :ok + # a driver thread waiting for the lock lets the garbage collector run. + # + # on macOS, Julia 1.14's safepoint handler identifies the faulting thread by its pthread + # id without skipping threads that have exited (JuliaLang/julia#63893). a foreign + # thread that reuses the id of one that exited, like the one above, is then resumed + # instead of parked, and the collector waits for it forever. + # TODO: bound the version range once this is fixed upstream + if Sys.isapple() && VERSION >= v"1.14.0-DEV" + @test_skip "collecting while a foreign thread waits for the lock" + else + c = GPUToolbox.Completion() + @atomic c.state = GPUToolbox.PENDING + GC.@preserve c begin + lock(c.cond) + signal_later(pointer_from_objref(c), 0) + @gcsafe_ccall uv_sleep(10::Cuint)::Cvoid + GC.gc() + unlock(c.cond) + @test timedwait(() -> (@atomic c.state) == GPUToolbox.RELEASED, 30) === :ok + end end end