Skip to content

fix: invalidate unique shape when property attributes change in place - #2

Closed
Beehtrix wants to merge 1 commit into
mainfrom
fix/freeze-invalidates-cached-shape-5706
Closed

Beehtrix wants to merge 1 commit into
mainfrom
fix/freeze-invalidates-cached-shape-5706

Conversation

@Beehtrix

@Beehtrix Beehtrix commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Fork PR for bot review. Refs boa-dev#5706


Summary by cubic

Fixes the Boa engine retaining stale inline caches when a property's attributes change in place, such as when Object.freeze changes writability. Instead of reusing the existing unique shape, a new unique shape is created so cached writes invalidate correctly.

Adds a regression test verifying that a previously cached write throws a TypeError after freezing.

Written for commit 7f3e54b. Summary will update on new commits.

View guided diff Turn on auto-fix


Summary by Gitar

  • Shape invalidation:
    • Recreate UniqueShape when property attributes change in place, so stale inline caches are invalidated
  • Tests:
    • Added freeze_invalidates_cached_unique_shape_write regression test for issue 5706

This will update automatically on new commits.

Copilot AI lite review requested due to automatic review settings December 3, 2026 07:27
@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Sorry @Beehtrix, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 days and 9 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where writing to a property after an object was frozen could fail to raise a TypeError in strict mode. The property now retains its existing value when the write is rejected.

The same-width attribute-change path now creates a new UniqueShape instead of cloning the current shape. A regression test checks that freezing an object prevents a later strict-mode write from changing its stored property value.

Changes: Unique shape writes

Layer / File(s) Summary
Same-width shape transition and regression test
core/engine/src/object/shape/unique_shape.rs, core/engine/src/tests/mod.rs
The same-width attribute-change path moves the property table and prototype into a new UniqueShape and returns ChangeTransitionAction::Nothing. The regression test checks that a strict-mode write after freezing throws TypeError and leaves y at 1.

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

Change: Bug fix

Suggested reviewers: halidodat

Merge Risk: Minimal · up to 7f3e5

This change makes frozen objects reliably reject later writes by giving the object a fresh shape when a property's attributes change in place. The change is small and has one direct caller, and no merge-blocking risk was found.

Security architecture risk: Minimal · up to 7f3e5

Boa now gives an object a fresh shape when property attributes change without changing the slot layout. This prevents a cached write from carrying forward permissions that the object no longer grants. The change is confined to the engine and does not require a deployment or data migration.

Security review details

Security Blast Radius

  • inferred — The inspected effect is on property access sites that cache a slot against the affected object's unique shape. The PR changes whether the existing fast path can be used; it adds no new way for scripts to reach that path.

Trust Boundaries and Controls

  • observed — A JavaScript property write can use a cached slot only if the cache entry matches the object's current shape. On a miss, the VM calls the normal property setter and turns a rejected strict-mode write into a TypeError.

Resilience and Maintainability Implications

  • inferred — PropertyMap installs the replacement before continuing the write; there is no deferred storage-layout update to complete or recover. A stale weak entry need not be collected for invalidation to work because its identity cannot match the replacement. This protects the inspected cache path, but does not make a separately retained predecessor a valid snapshot: its table and prototype have been moved out.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the primary change: a unique shape is now invalidated when property attributes change in place. The raw summary confirms change_attributes_transition now creates a new UniqueShape …
Description check Passed The description is related to the changeset. It explains that a stale inline cache is retained when property attributes change in place, that a new unique shape is created instead of reusing the exist…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the primary change: a unique shape is now invalidated when property attributes change in place. The raw summary confirms change_attributes_transition now creates a new UniqueShape instead of returning a clone of the existing shape when attribute width is unchanged. The title is specific and matches the changeset.

Full details: Description check

Explanation

The description is related to the changeset. It explains that a stale inline cache is retained when property attributes change in place, that a new unique shape is created instead of reusing the existing one, and that a regression test covers a cached write throwing a TypeError after freezing. This matches the raw summary of the changes in unique_shape.rs and tests/mod.rs.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the shape’s new way,
Then freezes it before the next write.
“TypeError,” says the engine; the value stays,
At one, unchanged through the night.
I twitch my nose and hop away.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 84c7c811-efb1-4ff1-b292-6600a8539944
Commits

Reviewing files that changed from the base of the PR and between 2d8a534 and 7f3e54b.

Files selected for processing: 2

  • core/engine/src/object/shape/unique_shape.rs
  • core/engine/src/tests/mod.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Recent review details

Context from checks skipped due to timeout: 1

  • GitHub Check: CodeRabbit

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T07:28:52.982246Z 7f3e54b PR opened
🔒 Security Review ✅ Completed 2026-12-03T07:30:42.621976Z 7f3e54b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gitar-bot

gitar-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

Beehtrix commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

Opened upstream as boa-dev#5720.

@Beehtrix Beehtrix closed this Dec 3, 2026
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.

2 participants