Skip to content

fix(array): route collection reads before array validation - #8061

Merged
proggeramlug merged 3 commits into
mainfrom
fix/8060-map-set-index
Aug 14, 2026
Merged

fix(array): route collection reads before array validation#8061
proggeramlug merged 3 commits into
mainfrom
fix/8060-map-set-index

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route managed-header-tagged, authoritative-registry-confirmed Map/Set indexed reads before clean_arr_ptr's strict array-only validation
  • leave fix(gc): install array growth forwarding for low-address arenas #8041's non-array rejection unchanged and assert that Map/Set still fail the array-only funnel
  • reuse the pre-clean header tag for ordinary arrays, rereading only when cleaning resolves a forwarded array head

Fixes #8060.

Causal evidence

Exact base: ef6e111a4fb85dcc9fd81f69c30bf57a0bf40a61.

#8041 made clean_arr_ptr reject every tracked non-array, but js_array_get_f64 reached its Map/Set branches only after that rejection. Six pre-existing tests failed individually with NaN instead of collection values. js_array_length was the positive control: it already consulted the managed tag and authoritative registry before cleaning, and returned the correct sizes for the same receivers.

Local validation

Using isolated worktree and target:

  • all six formerly failing tests: 20/20 fresh-process runs each
  • array collection-tag tests: 6/6
  • dynamic-index collection-tag tests: 3/3
  • typed-feedback tests: 49/49
  • array-subclass strict-cleaning controls: 6/6
  • array/forwarding tests: 74/74
  • cargo check -p perry-runtime --lib
  • cargo fmt --all --check
  • git diff --check

One full default-parallel runtime suite after the fix reported 2,313 passed, 1 failed, 4 ignored. The sole failure was promise::keyed_table::tests::settling_many_keys_is_not_quadratic, the independently diagnosed wall-clock assertion replaced by #8059; all six #8060 tests and the shadow-root witness passed.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed indexed reads on Map and Set values so they no longer incorrectly return NaN.
    • Out-of-range indexed reads now consistently return undefined.
    • Improved handling of collection-backed and forwarded array-like values during indexed access.
  • Tests

    • Added coverage validating correct Map and Set indexing behavior, pointer validation, registry-backed reads, and collection size reporting.
  • Documentation

    • Added a changelog entry describing the corrected collection indexing behavior.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 59ffc17d-b535-4152-acd5-a3f1c35632c9

📥 Commits

Reviewing files that changed from the base of the PR and between a2c90a1 and ef62f0d.

📒 Files selected for processing (1)
  • crates/perry-runtime/src/array/indexing.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/perry-runtime/src/array/indexing.rs

📝 Walkthrough

Walkthrough

js_array_get_f64 now routes registered Map and Set receivers before strict array pointer validation. It preserves array forwarding behavior, returns undefined for out-of-range collection reads, and adds receiver validation tests and changelog coverage.

Changes

Map and Set indexed-read fix

Layer / File(s) Summary
Collection dispatch and pointer validation
crates/perry-runtime/src/array/indexing.rs, crates/perry-runtime/src/array/collection_tag_tests.rs, changelog.d/8061-collection-index-before-array-clean.md
js_array_get_f64 checks registered Map and Set receivers before array pointer cleaning, reads collection entries with bounds checks, preserves forwarded-array tag handling, and adds regression assertions and changelog documentation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to ef62f

The change routes Map/Set indexed reads before strict array validation while preserving rejection of non-array inputs through the array-only path; no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

  • PerryTS/perry#7603: Both changes update clean_arr_ptr and array indexed-read dispatch for collection receivers.
  • PerryTS/perry#7765: Both changes modify js_array_get_f64 and collection-tag tests for Map and Set handling.
  • PerryTS/perry#7880: Both changes update Map and Set registry dispatch before array-pointer validation.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes routing collection reads before strict array validation.
Description check ✅ Passed The description provides the change summary, implementation details, linked issue, and detailed validation results.
Linked Issues check ✅ Passed The changes satisfy #8060 by preserving strict non-array rejection and restoring validated Map/Set indexed reads before array cleaning.
Out of Scope Changes check ✅ Passed The code, regression tests, and changelog entry directly support the linked issue and stated pull request objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/8060-map-set-index

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug
proggeramlug marked this pull request as ready for review August 14, 2026 00:25
@proggeramlug

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@proggeramlug
proggeramlug merged commit 118f49d into main Aug 14, 2026
3 of 22 checks passed
@proggeramlug
proggeramlug deleted the fix/8060-map-set-index branch August 14, 2026 00:39
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.

Map/Set indexed reads return NaN after array pointer hardening

1 participant