ArrayBuffer.prototype.resize does not apply ToIndex to its argument
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
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- c, javascript
Direzione di ricerca
Start by locating the shared implementation of ArrayBuffer.prototype.resize and SharedArrayBuffer.prototype.grow in QuickJS-ng; the issue does not name source files or tests. Compare argument conversion and validation order with the specified ToIndex behavior, then run or add cases for Infinity, values above 2^53−1, and a throwing valueOf. Done means these cases throw the expected errors without changing buffer length.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Reproduction
const b = new ArrayBuffer(8, { maxByteLength: 16 });
b.resize(Infinity);
print(b.byteLength);
Expected
A RangeError is thrown and the buffer keeps its length.
V8 (15.6.20):
$ v8 -e 'const b = new ArrayBuffer(8, { maxByteLength: 16 }); b.resize(Infinity); print(b.byteLength);'
RangeError: ArrayBuffer.prototype.resize: Invalid length parameter
Actual (QuickJS-ng)
QuickJS-ng resizes the buffer to 0:
$ qjs -e 'const b = new ArrayBuffer(8, { maxByteLength: 16 }); b.resize(Infinity); print(b.byteLength);'
0
Spec
ArrayBuffer.prototype.resize converts its argument with ToIndex, which throws a RangeError for +∞ and for any integer above 2^53 - 1.
QuickJS-ng instead converts it modulo 2^64, so large values wrap into range rather than being rejected:
$ qjs -e 'const b = new ArrayBuffer(8, { maxByteLength: 8192 }); b.resize(2 ** 64 + 4096); print(b.byteLength);'
4096 # V8: RangeError
The same method also converts the argument too early. Its first step, RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]), throws a TypeError for a buffer that is not resizable, before ToIndex runs:
$ qjs -e 'new ArrayBuffer(8).resize({ valueOf() { throw 0; } });'
0 # V8: TypeError: Method ArrayBuffer.prototype.resize called on incompatible receiver #<ArrayBuffer>
SharedArrayBuffer.prototype.grow shares the implementation and shows both symptoms: grow(2 ** 64 + 4096) on a buffer with maxByteLength: 8192 grows it to 4096, and new SharedArrayBuffer(8).grow({ valueOf() { throw 0; } }) throws 0. Negative values are handled correctly (resize(-1) is a RangeError). This is separate from #1729, which is about the error type of transfer.
JavaScriptCore, SpiderMonkey, GraalJS and V8 all throw a RangeError for resize(Infinity).
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di quickjs-ng/quickjs
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
quickjs-ng/quickjs#1836 ·
I maintainer di solito rispondono entro 2 giorni
-
Array.prototype.find frees an element twice when interrupted between iterationsForse già presa @josefguenther l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
quickjs-ng/quickjs#1792 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Object.prototype.propertyIsEnumerable converts `this` before the property keyForse già presa @SomSamantray l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
quickjs-ng/quickjs#1772 ·
I maintainer di solito rispondono entro 2 giorni
-
Deserialization corrupts data or returns `undefined` when a RegExp precedes a shared object referenceForse già presa @Sree24-ui l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
quickjs-ng/quickjs#1771 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
quickjs-ng/quickjs#1835 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di quickjs-ng/quickjs
Issue simili
-
v9.6.0: CMake incorrectly enforces presence of libevdevForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Unhandled ValueError terminates watchdog thread when GISRC value contains multiple colonsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug Component component: net
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
RT-Thread/rt-thread#11913 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
contiki-ng/contiki-ng#3289 ·
I maintainer di solito rispondono entro 3 giorni
-
area:docs help wanted type:enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno