YJIT: Fix potential infinite loop when OOM (GH-13186) #13193
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.
Avoid generating an infinite loop in the case where:
first
is adjacent to blocksecond
, and the branch fromfirst
tosecond
is a fallthrough, andsecond
immediately exits to the interpreter, andsecond
is invalidated and YJIT is OOMWhile pondering how to fix this, I think I've stumbled on another related edge case:
incoming_one
andincoming_two
both branch to blocksecond
. Blockincoming_one
has a fallthroughsecond
immediately exits to the interpreter (so it starts with its exit)second
is invalidated, the incoming fallthrough branch fromincoming_one
might be rewritten first, which overwrites the start of blocksecond
with a jump to a new branch stub.incoming_two
is then rewritten, but because we'reOOM we can't generate a new stub, so we use
second
's exit as the branchtarget. However
second
's exit was already overwritten with a jump to thebranch stub for
incoming_one
, soincoming_two
will end up jumping toincoming_one
's branch stub.Backport [Bug #21257]