Properly track deferred syscall patching with the syscall event #3881
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 fixes #3880 by moving the deferred syscall patching flag from Task to the corresponding syscall event. Both to avoid the assertion in that issue and for performance (since unpatched syscalls are traced), it is important that we (attempt to) patch the correct syscall ip.
Additionally, we add the ability for tests to make sure that a particular syscall was actually patched. In particular, our logic for bailing out when another task is in the patch region was accidentally preventing all future attempts at patching the same region, even if doing so would have succeeded. With that fixed up, the new test will make sure this doesn't regress.
As a side node for now, I'm not particularly convinced by the whole EV_SYSCALL_INTERRUPTION setup. Linux doesn't really have the concept - it just prepares the restart as it writes out the signal frame. To the extent that the presence or non-presence of
EV_SYSCALL_INTERRUPTION
on the stack has a semantic effect on howrr
behaves, that's probably a sign that we're not matching Linux behavior properly, since it doesn't have this state. The change I made here works for our existing tests and the new tests, but it's probably not fully general.