Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

ArrayBuffer.prototype.transfer throws a TypeError instead of a RangeError on a resizable buffer

Abierto
#1,729 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
57/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, javascript
Área
backend

Línea de trabajo

Start by tracing ArrayBuffer.prototype.transfer through ArrayBufferCopyAndDetach to the allocation path for resizable buffers, then compare how that path reports allocation failures with the non-resizable case. Add a regression test for the reproduction in the issue and run the relevant ArrayBuffer tests; done when the resizable-buffer call throws RangeError while existing cases still pass.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Reproduction
new ArrayBuffer(8, { maxByteLength: 16 }).transfer(Number.MAX_SAFE_INTEGER);
Expected

A RangeError is thrown.

V8 (15.6.20):

d8> new ArrayBuffer(8, { maxByteLength: 16 }).transfer(Number.MAX_SAFE_INTEGER);
RangeError: ArrayBuffer.prototype.transfer: Invalid length parameter
Actual (QuickJS-ng)

QuickJS-ng reports the rejected length as a type error:

qjs > new ArrayBuffer(8, { maxByteLength: 16 }).transfer(Number.MAX_SAFE_INTEGER);
TypeError: invalid array buffer length
Spec

ArrayBuffer.prototype.transfer calls ArrayBufferCopyAndDetach with preserve-resizability, which converts newLength with ToIndex and keeps the source's [[ArrayBufferMaxByteLength]] as newMaxByteLength.

2 ** 53 - 1 is a valid index, so it reaches AllocateArrayBuffer. That operation throws a RangeError when byteLength exceeds maxByteLength, and every remaining allocation failure in it is a RangeError as well. No step on this path produces a TypeError.

The error type depends on resizability: new ArrayBuffer(8).transfer(Number.MAX_SAFE_INTEGER) is a RangeError in QuickJS-ng, and so is transfer(2 ** 53), which ToIndex rejects before allocation. Only the resizable buffer takes the TypeError path.

Versions
  • QuickJS-ng: 0.17.0
  • V8: 15.6.20
Lenguaje dominante
C
Estrellas
3.9k
Forks
389
Merge medio
2 d 17 h
PR fusionados (30 d)
21

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de quickjs-ng/quickjs

Todos los issues de quickjs-ng/quickjs

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.