Fix crash in Bun.build with many conditions#30514
Closed
robobun wants to merge 1 commit into
Closed
Conversation
The expression 'if (allow_addons) 1 else 0 + conditions.len' parses as 'if (allow_addons) 1 else (0 + conditions.len)', so when allow_addons is true (the default), conditions.len is dropped from the reserved capacity, causing putAssumeCapacity to overflow when enough conditions are passed to Bun.build().
Collaborator
Author
Contributor
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
Collaborator
Author
|
Duplicate of #30466. |
Contributor
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
Disabled knowledge base sources:
WalkthroughESMConditions capacity computation is simplified to use ChangesBundler Conditions Capacity Fix
Comment |
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.
What does this PR do?
Fixes an operator precedence bug in
ESMConditions.initthat caused a debug assertion failure (and potential memory corruption in release) when passing severalconditionstoBun.build().The expression:
parses as:
So when
allow_addonsistrue(the default),conditions.lenis dropped from the reserved capacity and subsequentputAssumeCapacitycalls overflow the map.How did you verify your code works?
Added a regression test that passes 10 conditions to
Bun.build(). Before this fix it triggersreached unreachable codeinMultiArrayList.addOneAssumeCapacity; after the fix it builds successfully.Found by Fuzzilli (fingerprint
fdba7e39f969672c).