Make wide flag thread-local in Utility.codeToString#502
Merged
Conversation
shared static wide bleeds between threads disassembling code, making one thread decode the next local-variable index as 2 bytes instead of 1; keep it per-thread like the adjacent CONSUMER_CHARS.
garydgregory
requested changes
Jun 15, 2026
| try { | ||
| Utility.codeToString(new ByteSequence(new byte[] {(byte) Const.WIDE}), new ConstantPool(), false); | ||
| } catch (final Exception e) { | ||
| throw new AssertionError(e); |
Member
There was a problem hiding this comment.
You could call org.junit.jupiter.api.Assertions.fail(String, Throwable) here.
Contributor
Author
There was a problem hiding this comment.
done, switched both catch blocks to fail(String, Throwable).
| // iload with a single index byte; the trailing 0x02 must stay unread. | ||
| reader.set(Utility.codeToString(new ByteSequence(new byte[] {(byte) Const.ILOAD, 1, 2}), new ConstantPool(), false)); | ||
| } catch (final Exception e) { | ||
| throw new AssertionError(e); |
Member
There was a problem hiding this comment.
You could call org.junit.jupiter.api.Assertions.fail(String, Throwable) here.
garydgregory
added a commit
that referenced
this pull request
Jun 16, 2026
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.
Utility.codeToStringkeeps theWIDE-prefix state in a mutable staticboolean wide, so the flag is shared by every caller. Disassembling aWIDEopcode on one thread sets it, and a different thread decoding its next local-variable instruction (iload,istore,ret,iinc, ...) then reads a 2-byte index instead of 1 and misparses the rest of that method's code. The generic parser already avoids this by keepingwidea local inInstruction.readInstruction, and the adjacentCONSUMER_CHARSsignature-parser state in this same class was likewise moved to aThreadLocal. This does the same forwideand updates the five read/clear/set sites.Found by comparing the two
widehandlers. The addedUtilityTestregression reproduces it deterministically: aWIDEdisassembled on one thread makes aniloadon another thread decode%258instead of%1, and it fails without the change.mvn; that'smvnon the command line by itself.