tableFromIPC runs out of memory on a corrupted dictionary batch header instead of throwing

Abierto
#526 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript, typescript

Línea de trabajo

Start by tracing tableFromIPC and RecordBatchReader through the IPC message header parsing and buffer allocation paths; the issue names no source files or tests. Check how declared nodes and buffers lengths are validated against available metadata, then add coverage using the supplied corrupted dictionary batch reproduction. Done means decoding rejects the malformed header with an error instead of exhausting memory.

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

Descripción

Describe the bug, including details regarding any error messages, version, and platform.

Decoding an IPC stream with one corrupted vector length in a dictionary batch header makes tableFromIPC allocate until the process aborts with JavaScript heap out of memory, instead of throwing an error.

Version and platform: apache-arrow 21.2.0 (also 21.1.0), Node v26.13.0, macOS arm64.

Reproduction. The bytes are a valid stream from tableToIPC(tableFromArrays({ id: Int32Array.from([0, 0]), name: ["", ""] }), "stream"). Without the patch line it decodes 2 rows. (name is dictionary-encoded, so the stream holds a dictionary batch.) With it, the dictionary batch's buffers vector length goes from 3 to 0x06000003:

import { tableFromIPC } from "apache-arrow";

const bytes = Buffer.from(
  "/////9gAAAAQAAAAAAAKABAADgAHAAgACgAAAAAAAAEIAAAAAAAEAKj///8EAAAAAgAAAHgAAAAUAAAAEAAcAAgADwAXABgABAAQABAAAAA4AAAAFAAAAAAAAAEYAAAAAAAABRgAAAAEAAAAbmFtZQAAAAAAAAAABAAEAAQAAAAIAAgAAAAEAAgAAAAEAAAAxP///wAAAAEgAAAAEAAUAAQAAAAPABAAAAAIABAAAAAQAAAAFAAAAAAAAAIYAAAAAgAAAGlkAAAAAAAACAAMAAgABwAIAAAAAAAAASAAAAD/////sAAAABQAAAAAAAAADAAcABoAEwAUAAQADAAAAAgAAAAAAAAAAAAAAAAAAAIQAAAAAAAEAAgACgAAAAQACAAAABAAAAAAAAoAGAAMAAgABAAKAAAAFAAAAEgAAAABAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////uAAAABQAAAAAAAAADAAWABQADwAQAAQADAAAABAAAAAAAAAAAAAAAxAAAAAEAAoAGAAMAAgABAAKAAAAFAAAAFgAAAACAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAAAAAAACAAAAAgAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAA=",
  "base64"
);
bytes[335] = 6;
tableFromIPC(bytes);

Observed: with the default heap, it runs for about 56 seconds, reaches about 2.7 GB resident and aborts:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

The same happens with byte 334 set to 255, and with the same header's nodes length (bytes 390 and 391). With --max-old-space-size=256 it aborts in a few seconds.

Expected: a thrown error saying the header is invalid. A vector length in a message header can't be larger than the metadata that holds it, so the reader could check each declared length (for example a batch's nodes and buffers) against the bytes present before allocating.

Why it matters: anything that decodes IPC it didn't produce, such as an Arrow Flight client reading FlightData from a server, can be stopped by one bad message. We now run a bounds check before decoding in our own Flight client, but every other consumer of tableFromIPC and RecordBatchReader is still exposed.

Lenguaje dominante
TypeScript
Estrellas
114
Forks
35
Merge medio
13 h 35 min
PR fusionados (30 d)
5

Preparar el entorno

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 apache/arrow-js

Todos los issues de apache/arrow-js

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.