-
-
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
Libc.errno()
and GC safepoints
#55895
Comments
errno is async and safepoint safe (and codegen, etc). Did you run into any counterexample that someone broke recently? |
Wouldn't errno potentially get changed if we run a gc in between and somehow that thread does a syscall? |
Only if someone has introduced a bug into the GC recently (which may be possible, as Windows is known to fairly eagerly smash errno, unlike posix which is only supposed to smash it on failures): Lines 3308 to 3311 in e4b29f7
|
I don't have a concrete failure in mind, this was more prompted by a recent Slack conversation where I realized I didn't know the rules of the Game. I see that the usr2 handler is restoring errno, but I didn't see the same logic in the segv handler for the safepoint. Now maybe all that code doesn't touch errno xD |
errno
is a peculiar function since one must guarantee that no other code was executed on the thread between the function that seterrno
and the query.As far as I know we currently don't have a way to express that kind of atomicity, and we currently rely on the fact that in most cases the
Libc.errno()
function is inlined.If that function were not inlined there is the possibility for it to hit the safepoint on function entry. As far as I know
errno
is not interrupt safe in general.This does not seem to be a problem in practice, but we maybe need a function annotation that blocks safepoint on entry, or at the very least mark
julia/base/libc.jl
Line 293 in 6f3fdf7
@inline
.We could also consider making sigatomic more user-friendly and recommending it's usage in the context of
errno
The text was updated successfully, but these errors were encountered: