Repository navigation
fix(ts): write through DerefMut of a pinned or plain &mut to a value JS copies - #245
Conversation
…JS copies Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 8972349
The plain-reference and single-Pin fixes address the right representation boundary, and the Arc/guard fixtures protect replacement and drop behavior. One instance of the same bug remains: nested Pin wrappers still lose the writable .v path (inline P2). This is an incomplete fix of the existing problem, not a newly introduced regression. Prefer resolving the erased pointer representation consistently rather than adding one-wrapper special cases.
Verification: independent static tracing of MIR alias lowering, task mappings, type representation and the changed fixtures. No compiler, differential tests or census run performed; author check claims were not independently verified.
(Written by OpenAI)
| }); | ||
| let place = match lent { | ||
| Some(lent) if self.b.t.place_pointee(lent).is_some() => place.member("v"), | ||
| _ => place, |
There was a problem hiding this comment.
[P2] Resolve nested Pin wrappers before choosing the writable path
The new logic peels only one Pin. The existing fixture helper can also be called as write_through(Pin::new(Pin::new(&mut byte)), 1): both Pins erase recursively to rt.Place<u8> and both constructors are identity mappings. However, the outer DerefMut mapping returns that Place, while lent here is still Pin<&mut u8>, for which place_pointee returns None. The alias therefore points at the wrapper itself instead of its .v, so *p ^= by still fails to update byte (and emits the same invalid Place/scalar operation this PR fixes for one Pin). Resolve the nested pointer representation consistently and add this case to the differential fixture.
# Conflicts: # ts/fixtures/lang/expected/objects.ts # ts/fixtures/lang/src/objects.rs
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
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. Comment |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
A write through
DerefMutof a&mut, or a pin of one, to a value JS copies was wrong:*Pin::new(&mut byte) ^= 0x5alowered to_210 = _210 ^ 90, which overwrote thert.Placethe pin is instead of writing through itsv.tscrejects it, and the byte never changed.*p ^= bywithP = Pin<&mut u8>was wrong the same way.P = &mut u8was refused (<&mut u8 as DerefMut>::deref_mutwas unmapped).Found while fixing #238's online finding. It is on main and independent of that PR.
Approach
mir/call.rs: theDerefMutarm aliases its result as the pointee's path. A&mut, or a pin of one, that is anrt.Placehands back the place itself, so its path is now the place'sv.MutexGuard,RefMut, andPin<Box<Arc>>keep the paths their mappings already give.task.rs:Deref/DerefMutof a reference now maps for any pointee, not just the std types fix(ts): deref a reference to an Arc, a lock, or a pin as the reference #236 listed:derefreadspointee_value;deref_mutlends the reference.No other snapshot changed.
Fixture:
ts/fixtures/lang/src/objects.rswrites a byte throughDerefMutofPin<&mut u8>directly, and through a genericDerefMutwithPin<&mut u8>and&mut u8. It also replaces anArcthroughPin<&mut Arc>,&mut Arc, and aMutexGuard<Arc>, which were already correct and are now pinned by the differential.Impact
<&mut T as DerefMut>translates. No public API change.Alternatives
Pin<&mut T>'sderef_mutmapping return the place'sv. Rejected: outside the alias arm, thePin<&mut Arc>path needs the place itself, so only the arm that turns the result into a path knows to readv.Follow-ups
None. The census was not run for this change.
Review
Round 2:
quest review --responses, Codex withgpt-6.1-solat medium effort, on head0fee740dd6dbd3cedb428f2090ddcce2d70a2096againstorigin/mainatcff3177b. No findings.Since round 1 (on
6902e6b3):origin/mainat7edb4e5b, conflict-free.replaceThrough$Arc_u8inobjects.ts. It drops theconst _4 = palias, and the write staysp.v = _3into the caller's place. ThePinand guard variants are unchanged.just cipasses on the head.Merge of main at
692c17d2aaf819f339f90619be24449fc3ed13e1(adds #252): git merged it without conflicts, no snapshot changed, andjust cipassed on this exact tree; it is a recorded skip, too trivial to review, on top of round 2's clean review of0fee740d.🤖 Generated with Claude Code
(written by Claude Opus 5.5)