Skip to content

Fix StackMapFrame.CopyTo misrouting frame types 64-65 - #3

Merged
wasabii merged 1 commit into
mainfrom
fix-stackmapframe-copyto-boundary
Jul 18, 2026
Merged

Fix StackMapFrame.CopyTo misrouting frame types 64-65#3
wasabii merged 1 commit into
mainfrom
fix-stackmapframe-copyto-boundary

Conversation

@wasabii

@wasabii wasabii commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@

Summary

StackMapFrame.CopyTo (the encode dispatch) routes FrameType <= 65 to SameStackMapFrame. Per JVMS §4.7.4, same_frame is only frame_type 0–63; 64–127 is same_locals_1_stack_item_frame.

As a result, frame types 64 and 65 hit the (SameStackMapFrame)this cast, which itself asserts FrameType <= 63 and throws — so any method whose StackMapTable contains a same_locals_1_stack_item_frame with 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):

Frame frame_type
same_frame 0–63
same_locals_1_stack_item_frame 64–127
same_locals_1_stack_item_frame_extended 247
chop_frame 248–250
same_frame_extended 251
append_frame 252–254
full_frame 255

The decode/measure paths (TryMeasureData, AsSameStackMap) already use the correct <= 63 boundary — only this one encode dispatch had the typo.

Change

One line: FrameType is <= 65FrameType is <= 63, so 64–65 fall through to the same_locals_1_stack_item_frame branch.

Builds clean (0 errors). Independent of #2 (the Java 25 version bump); branched from main.

🤖 Generated with Claude Code
@

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>
@wasabii
wasabii merged commit e9560ac into main Jul 18, 2026
1 check passed
@wasabii
wasabii deleted the fix-stackmapframe-copyto-boundary branch July 18, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant