Repository navigation
fix(ts): measure offset_from across views of one byte buffer - #455
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
offset_frombetween two byte pointers into one buffer threwrust2-ts: offset_from of pointers JS keeps in different arrayswhen they came through different views of it. Example: a slice'sas_mut_ptrand the pointer of an element itsiter_mutgives. Native Rust measures the distance. Each pointer is anrt.AtIndexinto its ownUint8Array, andsubarraymakes a fresh one sharing the buffer. Found by review on #418 and recorded inquest/m3/ts-unsafe.md.Approach
rt.ptrOffsetFromtreats twoUint8Arrays over oneArrayBufferas one array, measuring by each view'sbyteOffsetplus the pointer's index. Every other pair of arrays still fails loudly. It is the only runtime operation that compares a pointer's array by identity:ptr::copyalready copies between views throughUint8Array.set, and translation refuses comparisons of element pointers.Impact
rt.ptrOffsetFromreturns the distance where it threw. No public API change, noMIGRATE.mdentry.quest/m3/ts-unsafe.md.Tests:
fixtures/lang/src/elements.rs'sedges, differential against native wasm32: within a subslice of a byte array, pointers fromas_mut_ptr, fromiter_mut's first and last elements, and fromsplit_at_mut's second part, measured against each other both ways, then a write through a pointer moved by one such distance. Before the fix, those cases threw (181 differences); after it, they agree with native.Alternatives
Uint8Arrayper buffer, made byelemOf. Rejected: it would also let a pointer reach past its view into the rest of the buffer, such as aByteVec's spare capacity, which today fails loudly. That needs its own decision.Review
quest reviewby Codex, gpt-6.1-sol, medium effort. Round 1 on894deeaf: clean. Then main merged (feat(ts): hold a value by ManuallyDrop as the value, dropped only when asked #425 and fix(ffi): move a clone out of C++'s last shared copy while a future borrows it #451, conflict-free).just cipasses locally on0c64752339919d3f2146687254d5dbb002685cef(one commit behind main, feat(ts): translate &mut dyn Debug and &mut dyn Display #453, which touches onlyfmt).(written by Claude Opus 5.5)
🤖 Generated with Claude Code