-
-
Notifications
You must be signed in to change notification settings - Fork 159
fix(gc): root globalThis across its own lazy builtin population (#6982) #6994
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| ### Fixed | ||
|
|
||
| - **gc: `globalThis` lazy builtin population held a raw pointer across its own | ||
| allocations (#6982).** `js_get_global_this` registers *two* root slots for the | ||
| freshly allocated singleton (`THREAD_GLOBAL_THIS` and `GLOBAL_THIS_PTR`) | ||
| precisely so an evacuating collector rewrites them on a move — and then passed | ||
| the raw, pre-GC pointer by value into `populate_global_this_builtins`, which | ||
| installs several hundred builtins and allocates on nearly every step. When a | ||
| copying minor relocated the singleton mid-population, every later | ||
| `js_object_set_field_by_name(singleton, ..)` / | ||
| `set_builtin_property_attrs(singleton as usize, ..)` addressed the dead | ||
| from-space copy, whose bytes had already been recycled for freshly relocated | ||
| objects. `js_get_global_this` then returned that stale address too. | ||
|
|
||
| The singleton (plus the intermediate pointers in | ||
| `alias_number_static_to_global_function` and | ||
| `alias_typed_array_proto_to_string`) is now rooted in a `RuntimeHandleScope` | ||
| and re-read through the handle at every use, and `js_get_global_this` returns | ||
| the value re-read from its registered cache slot. Binding `singleton` as a | ||
| closure rather than a value makes the conversion exhaustive by construction — | ||
| any use that was not converted fails to compile. | ||
|
|
||
| Only reachable with the conservative native-stack scan off, which is what | ||
| production's `Auto -> SkipDisabled` resolves to; the scan was masking the bug | ||
| by pinning the argument register. This is the same class as #6951/#6972 (a raw | ||
| reference held across a collection point), one layer further out. | ||
|
|
||
| Measured on the #6981 representation corpus (macOS arm64, pinned Node 26.5.0, | ||
| `PERRY_GC_HEAP_LIMIT=8 PERRY_GC_INCREMENTAL=0 | ||
| PERRY_CONSERVATIVE_STACK_SCAN=off`, `copied_objects` > 0 on every run): | ||
|
|
||
| - crashes on the evacuating precise-roots arm: **6 -> 2** | ||
| (`repsel_canonical_i32`, `ta_param_numeric_read`, `typedarray_param_read`, | ||
| `repsel_ptr_shape_barriers` no longer crash); | ||
| - `repsel_canonical_i32` flips all the way to **OK** (byte-identical to Node), | ||
| the rest become mismatches — progress, still red, tracked separately; | ||
| - all 21 corpus files remain byte-identical to Node on the as-shipped | ||
| configuration (no regression). | ||
|
|
||
| Removing this shared first hurdle exposed two independent defects that were | ||
| previously masked by it: a compiled constructor's receiver going stale across | ||
| the same collection (`repsel_ptr_shape_locals`, still SIGSEGV) and a lost | ||
| method value (`repsel_proven_this_frozen`, now `TypeError: bump is not a | ||
| function`). Both are filed separately. | ||
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
Oops, something went wrong.
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the changelog heading.
This fragment must contain only the entry body;
### Fixedis a section header.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
Sources: Coding guidelines, Learnings