-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS: Adopting a thread during GC results in bus error #49928
Comments
Trying to think through the order of events here:
There is a window during which GC can be run, that will find the foreign thread in an partially setup state. Probably we need to move the signal-handler installation to earlier. Can we move it to before |
The GC is already running when
|
You are right. I still think my scenario is a possibility, but GC is definitly running.
So when we call In Lines 341 to 350 in 944b28c
Both old_state and state are 0.
We will need to move the signal handler initialization to before the |
Wouldn't it be safer to wait for the GC to end to let the thread enter? I'm not sure if the parallel GC stuff might play badly with this. |
The following MWE, using Metal.jl to launch code on a foreign thread, causes Julia to crash:
Running under LLDB reveals:
I'm not familiar with the thread adoption code, or how it acquires the necessary locks, but my guess is that the allocation that happens during task set-up triggers the usual GC safepoint which we fail to catch because we haven't installed signal handlers yet. @JeffBezanson mentions that the
jl_gc_unsafe_enter
at the start ofjl_adopt_thread
should have taken care about that though.Happy to create a MWE without Metal if anybody can suggest a timer-like API to start threads using a callback.
x-ref JuliaGPU/Metal.jl#138
The text was updated successfully, but these errors were encountered: