-
-
Notifications
You must be signed in to change notification settings - Fork 161
fix(runtime): in and destructuring on a Uint8Array with own properties (#9347)
#9435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
proggeramlug
merged 1 commit into
PerryTS:main
from
proggeramlug:fix/9347-uint8array-property-surfaces
Sep 2, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Uint8Array uses Perry's buffer representation while Int32Array uses the | ||
| // typed-array representation. Both must drive the iterator protocol during | ||
| // binding and assignment destructuring. | ||
| function makeValues<T extends Uint8Array | Int32Array>(value: T): T { | ||
| value[0] = 6; | ||
| value[1] = 7; | ||
| value[2] = 8; | ||
| return value; | ||
| } | ||
|
|
||
| function binding(label: string, value: Uint8Array | Int32Array): void { | ||
| const [first, ...rest] = value; | ||
| console.log(label, first, rest.join(",")); | ||
| } | ||
|
|
||
| function assignment(label: string, value: Uint8Array | Int32Array): void { | ||
| let first = 0; | ||
| let rest: number[] = []; | ||
| [first, ...rest] = value; | ||
| console.log(label, first, rest.join(",")); | ||
| } | ||
|
|
||
| const i32 = makeValues(new Int32Array(3)); | ||
| const u8 = makeValues(new Uint8Array(3)); | ||
|
|
||
| binding("binding-i32", i32); | ||
| binding("binding-u8", u8); | ||
| assignment("assignment-i32", i32); | ||
| assignment("assignment-u8", u8); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Uint8Array uses Perry's buffer representation while Int32Array uses the | ||
| // typed-array representation. Ordinary own properties must be visible to the | ||
| // `in` operator on both, including when the write is type-erased. | ||
| function inspect(label: string, value: Uint8Array | Int32Array): void { | ||
| (value as any).extra = 9; | ||
| console.log( | ||
| label, | ||
| "extra" in value, | ||
| value.hasOwnProperty("extra"), | ||
| Object.keys(value).join(","), | ||
| ); | ||
| } | ||
|
|
||
| inspect("i32", new Int32Array(1)); | ||
| inspect("u8", new Uint8Array(1)); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Root the iterator before the native dispatch.
named_fieldcan allocate and trigger the moving collector. This branch then readsiter_f64again foris_builtin_iterator_class_idand passes it tojs_native_call_method. If the iterator moved during the lookup, both operations use a stale pointer. Typed-array destructuring can then misclassify the iterator or crash.Keep the iterator in a
RuntimeHandleScopebefore the lookup. Re-read the NaN-boxed value from the handle for the class check and native call. Ensurenamed_fieldalso re-reads a rooted receiver after its allocation.Suggested rooting pattern
Also applies to: 1318-1324
🤖 Prompt for AI Agents