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

未关闭
#526 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
114
派生
35
平均合并
13 小时 35 分钟
30 天内合并 PR
5

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/arrow-js 的其他 Issue

查看 apache/arrow-js 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。