Fix a deadlock in syscallbuf unmapping after vfork #3826
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should be 🤞 a fix for #3807
It does two things to address that issue:
Firstly, moves the code for doing syscallbuf unmap after
vfork
/exec
out ofTask::post_exec
, and instead defers doing that until we next run a task in that address space. This means we should never leak address space just because there were no available threads to perform the unmapping. This doesn't actually do anything to technically fix the issue, but it means we can write some reliable tests around the syscallbuf unmapping stuff, so it seemed worthwhile.Secondly, we now look at the desched signal state in AutoRemoteSyscalls. If the desched signal is armed, we temporarily disarm it (and mask it too, in case the signal was pending but unprocessed). This is what should fix our issue, I think
It's hard to prove that this really has fixed the issue, but I left my reproduction script running for 12 hours last night and it didn't hang, and that had always been long enough to trigger the hang before. So I guess either this fixes the issue, or I got (un)lucky.
I'm sure my C++ isn't going to win any beauty contests here but hopefully this demonstrates the outlines of a fix.