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

Reflect.construct on a TypedArray reads the buffer before newTarget's prototype

Aperta
#1,739 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, javascript
Ambito
backend, testing

Direzione di ricerca

Start by tracing the TypedArray constructor’s buffer-argument path and compare its order of operations with the no-argument path described in the reproduction. Run the supplied qjs commands to confirm the mismatch; done means the buffer case raises the revoked-Proxy TypeError before inspecting the buffer, matching the expected behavior.

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

Descrizione

Reproduction
const r = Proxy.revocable(function(){}, {});
r.revoke();
Reflect.construct(Float32Array, [new ArrayBuffer(2)], r.proxy);
Expected

The TypeError raised by reading prototype from a revoked Proxy.

V8 (15.6.20):

$ v8 -e 'const r = Proxy.revocable(function(){}, {}); r.revoke(); Reflect.construct(Float32Array, [new ArrayBuffer(2)], r.proxy);'
unnamed:1: TypeError: Cannot perform 'get' on a proxy that has been revoked
Actual (QuickJS-ng)
$ qjs -e 'const r = Proxy.revocable(function(){}, {}); r.revoke(); Reflect.construct(Float32Array, [new ArrayBuffer(2)], r.proxy);'
RangeError: invalid length
Spec

The TypedArray constructor calls AllocateTypedArray before it looks at its first argument, and the first step of AllocateTypedArray is GetPrototypeFromConstructor, which reads Get(ctor, "prototype"). On a revoked Proxy that read throws, so nothing about the buffer or the length is ever computed.

Dropping the buffer argument makes QuickJS take the correct path, which localises the defect to the buffer branch:

$ qjs -e 'const r = Proxy.revocable(function(){}, {}); r.revoke(); Reflect.construct(Float32Array, [], r.proxy);'
TypeError: revoked proxy

JavaScriptCore, SpiderMonkey, GraalJS and V8 all raise a revoked-Proxy TypeError with the buffer argument present.

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.