Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

%TypedArray%.prototype.with converts its arguments before checking for a detached buffer

Aperta
#1,759 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, javascript
Ambito
backend

Direzione di ricerca

The report identifies %TypedArray%.prototype.with but does not name implementation or test files. Start by locating that method and its existing detached-buffer checks, then find the related tests for typed-array methods and run them. Done means the detached-buffer TypeError occurs before either argument's conversion, including when valueOf throws.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Reproduction
const b = new ArrayBuffer(8);
const v = new Int32Array(b);
b.transfer();
v.with(0, { valueOf() { throw 0; } });
Expected

A TypeError is thrown for the detached buffer, and valueOf is never called.

V8 (15.6.20):

$ v8 -e 'const b = new ArrayBuffer(8); const v = new Int32Array(b); b.transfer(); v.with(0, { valueOf() { throw 0; } });'
TypeError: Cannot perform %TypedArray%.prototype.with on a detached or out-of-bounds ArrayBuffer
Actual (QuickJS-ng)

QuickJS-ng converts the value first, so the 0 it throws propagates:

$ qjs -e 'const b = new ArrayBuffer(8); const v = new Int32Array(b); b.transfer(); v.with(0, { valueOf() { throw 0; } });'
0
Spec

%TypedArray%.prototype.with begins with ValidateTypedArray, which throws a TypeError when IsTypedArrayOutOfBounds is true. A view on a detached buffer is out of bounds, so the method must throw before it converts index with ToIntegerOrInfinity or value with ToNumber.

QuickJS-ng has the detached check, but only after both conversions: v.with(0, 1) throws TypeError: ArrayBuffer is detached or resized, and a throwing valueOf on the index (v.with({ valueOf() { throw 0; } }, 1)) also runs before it.

This is not what #1625 was about. PR #1667 changed which conversion is applied to value relative to the index check; the missing step here is the ValidateTypedArray that precedes both.

JavaScriptCore, SpiderMonkey, GraalJS and V8 all throw the TypeError.

Versions
  • QuickJS-ng: 0.17.0
  • V8: 15.6.20
Lingua principale
C
Stelle
3.9k
Fork
389
Merge medio
4g 1h
PR unite (30g)
24

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quickjs-ng/quickjs

Tutte le issue di quickjs-ng/quickjs

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.