-
Notifications
You must be signed in to change notification settings - Fork 334
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
Async callbacks break after forking if async_cb_thread gets started before forking #884
Comments
larskanis
added a commit
to larskanis/ffi
that referenced
this issue
Mar 5, 2021
After fork() the dispatcher thread is no longer running, so it needs to be restarted in the child process. Fixes ffi#884
Thank you for spotting this and providing the repro script! |
This was referenced Mar 8, 2021
Merged
This was referenced Mar 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello again! While having breakfast I got to wondering about the code I saw in #883 and I got curious -- what happens to the
async_cb_thread
after Ruby forks? And would that break async callbacks?It turns out that there's an issue hiding here.
Using the following test case (I just dropped it into the
ffi
repository and reused some of the test tools already there):When we don't run
poke_ffi
before thefork
, everything works as expected:But then we set
POKE_FFI_BEFORE_FORK=1
we break ffi in the forkI'm guessing this wasn't spotted so far because most Ruby frameworks/apps employ forking pretty early on in their lifecycle so they get lucky (?).
The text was updated successfully, but these errors were encountered: