FIX: don't drop requests that arrive before v8_roundtrip is re-entered - #440
Merged
Conversation
When an attached Ruby callback makes its own request on the same context (perform_microtask_checkpoint, a nested call, etc), the Ruby thread can enqueue its next request in the gap between the nested dispatch finishing and the V8 thread re-entering v8_roundtrip. The buf_reset(&c->req) on entry then destroyed that request, leaving both threads waiting on each other forever. The reset is a leftover from before 478c763, when v8_roundtrip returned a pointer into the live request buffer and had to clear it on the next entry. Requests are now handed off with buf_move, so the buffer is already empty on re-entry unless it holds a new, unread message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When an attached Ruby callback makes its own request on the same context (perform_microtask_checkpoint, a nested call, etc), the Ruby thread can enqueue its next request in the gap between the nested dispatch finishing and the V8 thread re-entering v8_roundtrip. The buf_reset(&c->req) on entry then destroyed that request, leaving both threads waiting on each other forever.
The reset is a leftover from before 478c763, when v8_roundtrip returned a pointer into the live request buffer and had to clear it on the next entry. Requests are now handed off with buf_move, so the buffer is already empty on re-entry unless it holds a new, unread message.
Writing a deterministic test here is very difficult. I was only able to reproduce by looping thousands of times.