-
-
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
When adopting a thread, spin until GC isn't running. #49934
Conversation
I'm not sure how to fix the analyzer error;
We can't annotate |
This only fixes part of the issue. You still need to fix the issue where we get past this check and then GC starts and we hit a safepoint without being able to execute that safepoint on this thread yet. |
c7cb0b0
to
1bd2f6a
Compare
Besides the discussion around memory model this looks.good to me. I will leave final review to @vtjnash and @JeffBezanson |
What happens if a thread calls |
|
Oh, I see it now we have a per thread check. |
Couple of CI hangs, with one printing the following backtrace:
So that seems related. |
Otherwise GC might run after the foreign thread exits the spin loop, but before it is initialized and ready to handle GC safepoints.
Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com>
Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com>
Stores already use seq_cst.
// introduce a race between it and this thread checking if the GC is enabled and only | ||
// then setting jl_gc_running. To avoid that, check again now that we won that race. | ||
if (jl_atomic_load_acquire(&jl_gc_disable_counter)) { | ||
jl_atomic_store_release(&jl_gc_running, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem logical to be a release, since there are no other stores in this function to act upon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you intended the much more expensive seq-cst semantics so that it establishes an atomic ordering with the prior load?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. The load during jl_adopt_thread
is an atomic acquire, which I intended to match with this release store. I'm not sure why it would need to be matched up with stores in this very function?
Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com> (cherry-picked from commit 4ef9fb1)
Fixes #49928, alternative to #49930.