Fix StackMapFrame.CopyTo misrouting frame types 64-65 - #3
Merged
Conversation
The encode dispatch in StackMapFrame.CopyTo routed FrameType <= 65 to SameStackMapFrame, but per JVMS 4.7.4 same_frame is only frame_type 0-63; 64-127 is same_locals_1_stack_item_frame. Frame types 64 and 65 therefore hit the (SameStackMapFrame)this cast, which itself asserts FrameType <= 63 and throws, making those frames impossible to re-encode. Correct the boundary to <= 63 so 64-65 fall through to the same_locals_1_stack_item_frame branch, matching the decode/measure paths which already use the correct boundary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
@
Summary
StackMapFrame.CopyTo(the encode dispatch) routesFrameType <= 65toSameStackMapFrame. Per JVMS §4.7.4,same_frameis onlyframe_type0–63; 64–127 issame_locals_1_stack_item_frame.As a result, frame types 64 and 65 hit the
(SameStackMapFrame)thiscast, which itself assertsFrameType <= 63and throws — so any method whose StackMapTable contains asame_locals_1_stack_item_framewith offset delta 0 or 1 (frame types 64/65) cannot be re-encoded.Verification
Confirmed the boundaries against the JVMS (Java SE 25, §4.7.4):
same_framesame_locals_1_stack_item_framesame_locals_1_stack_item_frame_extendedchop_framesame_frame_extendedappend_framefull_frameThe decode/measure paths (
TryMeasureData,AsSameStackMap) already use the correct<= 63boundary — only this one encode dispatch had the typo.Change
One line:
FrameType is <= 65→FrameType is <= 63, so 64–65 fall through to thesame_locals_1_stack_item_framebranch.Builds clean (0 errors). Independent of #2 (the Java 25 version bump); branched from
main.🤖 Generated with Claude Code
@