Skip to content

Editorial: fix incorrect assertion in TA.prototype.{filter,with} - #3979

Open
bakkot wants to merge 2 commits into
tc39:mainfrom
bakkot:fix-ta-throwy
Open

bakkot wants to merge 2 commits into
tc39:mainfrom
bakkot:fix-ta-throwy

Conversation

@bakkot

@bakkot bakkot commented Sep 17, 2026

Copy link
Copy Markdown
Member

Fixes #3978. That was closed because it was opened by an LLM without permission but it really is a bug, observable with

let rab = new ArrayBuffer(16, { maxByteLength: 16 });
let ta = new BigInt64Array(rab);

ta.with(0, { valueOf() { rab.resize(8); return 0n; } });

and

let rab = new ArrayBuffer(16, { maxByteLength: 16 });
let ta = new BigInt64Array(rab);

ta.filter(() => { rab.resize(8); return true; });

and

let rab = new ArrayBuffer(16);
let ta = new BigInt64Array(rab);

ta.filter(() => { if (!rab.detached) rab.transfer(); return true; });

Bug report didn't mention detaching but it comes up for filter; afaict it does not for with (because the coercions happen before the IsValidIntegerIndex check, which always returns false for detached buffers).

@github-actions

Copy link
Copy Markdown

The rendered spec preview for this PR is available as a single page at https://tc39.es/ecma262/pr/3979 and as multiple pages at https://tc39.es/ecma262/pr/3979/multipage .

@linusg linusg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Confirmed that this causes assertion failures in at least Boa and Kiesel, might be good to add test262 coverage.

@bakkot

bakkot commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

might be good to add test262 coverage

Good thought, done.

lahma added a commit to sebastienros/jint that referenced this pull request Sep 24, 2026
…rinking coercion (#4157)

Moves SuiteGitSha 35d56660 -> 7ab7fafa (5 upstream commits, test-only, no
features.txt change) and recomputes CorpusContentSha256 over the new tree.

%TypedArray%.prototype.with bulk-copied the length it read before coercing
the index and the value, so a coercion that shrank a resizable buffer made
Array.Copy read past the reallocated block and a CLR ArgumentException
escaped into the host. It now copies only the elements the source still
has and writes undefined through TypedArraySetElement for the rest (NaN,
+0, or a TypeError for BigInt), per tc39/ecma262#3979 as tested by
tc39/test262#5136.

intl402/DateTimeFormat/prototype/format/german-weekday-no-year.js parks
under the INTL402 banner: it needs CLDR availableFormats skeleton matching
and format-context weekday names, which the component-bag lane lacks.


Claude-Session: https://claude.ai/code/session_01PanPJbBD7pQC9fRiTpHxvs

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypedArray copy methods can reach abrupt element writes after RAB shrink

3 participants