Skip to content

fix(codegen): root the URL setters and forEach operands; url_main.rs is clean - #7464

Merged
proggeramlug merged 2 commits into
mainfrom
fix/layer1-url-setters-rooting
Aug 5, 2026
Merged

fix(codegen): root the URL setters and forEach operands; url_main.rs is clean#7464
proggeramlug merged 2 commits into
mainfrom
fix/layer1-url-setters-rooting

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Closes the last two shapes in url_main.rs.

Nine setters in one arm

UrlSetPathname | Search | Hash | Protocol | Hostname | Port | Username | Password | Href share a single match arm, so one fix covers all nine. The receiver was unboxed to a raw heap pointer and then value lowered — arbitrary user code — before the runtime call used it.

forEach had two windows, not one

The receiver crossed the callback lowering, and both it and the callback crossed this_arg's. All operands are rooted together, this_arg included when present.

The file is now clean, by an arm-aware audit

UrlPatternNew / UrlSetHref / UrlSearchParams{Get,Has,Set,Append,Delete,ForEach,GetAll}
  9 guards, each with exactly one top-level release
  0 remaining raw-pointer-across-lowering sites

Both properties are checked by script rather than by reading, because on this file "it compiles" has now twice failed to catch a real defect — an unbound guard that emitted no truncate (#7462), and a release placed inside one branch of an if/else (#7463).

Correcting the earlier count

My previous scan reported "9 remaining". Three were false positives: it crossed match-arm boundaries and paired a receiver with the next arm's lower_expr. Entries, Keys and Values use their receiver immediately with nothing in between. The scan is now arm-aware.

Verification

  • 12/12 URL-family gap tests byte-identical to the pinned Node oracle
  • a setters + forEach repro with allocating arguments matches node exactly (/p5 true 4) and is unchanged under PERRY_GC_HEAP_LIMIT=8 PERRY_GC_FORCE_EVACUATE=1
  • cargo fmt --check clean

Summary by CodeRabbit

  • Bug Fixes
    • Fixed URL setter operations to remain reliable when callbacks or other user code runs during updates.
    • Improved URLSearchParams.forEach behavior, including handling of callbacks and optional context values.
    • Added coverage confirming consistent behavior across URL APIs and memory-management scenarios.

Ralph Küpper added 2 commits August 5, 2026 18:07
…is clean

Closes the last two shapes in this file.

The nine URL setters share one match arm, so a single fix covers
pathname/search/hash/protocol/hostname/port/username/password/href: the
receiver was unboxed to a raw heap pointer and then `value` lowered --
arbitrary user code -- before the runtime call used it.

forEach had TWO windows, not one: the receiver crossed the `callback`
lowering, and both it and the callback crossed `this_arg`'s. All operands
are rooted together, `this_arg` included when present.

Arm-aware audit of the whole file now reports:

  9 guards, each with exactly one top-level release
  0 remaining raw-pointer-across-lowering sites

The earlier scan's "9 remaining" included three false positives -- it
crossed match-arm boundaries and paired a receiver with the NEXT arm's
lower_expr. Entries/Keys/Values use their receiver immediately.

URL-family gap tests byte-identical to node; a setters+forEach repro with
allocating arguments matches node and is clean under
PERRY_GC_HEAP_LIMIT=8 PERRY_GC_FORCE_EVACUATE=1.
@proggeramlug
proggeramlug merged commit 5b92c72 into main Aug 5, 2026
1 check was pending
@proggeramlug
proggeramlug deleted the fix/layer1-url-setters-rooting branch August 5, 2026 16:08
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@proggeramlug, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 532b054b-438a-484a-8559-a1b2493af733

📥 Commits

Reviewing files that changed from the base of the PR and between 14d046b and f693dc0.

📒 Files selected for processing (2)
  • changelog.d/7464-url-setters-rooting.md
  • crates/perry-codegen/src/expr/url_main.rs
📝 Walkthrough

Walkthrough

URL setters and URLSearchParams.forEach now root operands across user-code lowering, reload them before runtime calls, and release root guards afterward. The changelog records the fixes and validation results.

Changes

URL operand rooting

Layer / File(s) Summary
Root and reload URL operands
crates/perry-codegen/src/expr/url_main.rs, changelog.d/7464-url-setters-rooting.md
URL setters root receivers and assigned values together. URLSearchParams.forEach roots params, callback, and optional thisArg, then reloads operands before invocation. The changelog documents the audit and test results.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: thehypnoo

✨ 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/layer1-url-setters-rooting

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.

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.

1 participant