[GH-ISSUE #8952] [Bug] CUBIN symbol string scan limit is reported as malformed input #7867

Open
opened 2026-11-05 02:37:35 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @xu91102 on GitHub (Nov 5, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/8952

Observed behavior

On unmodified main 71f680d7c1aa7a45ba0325fe87b104744b0c105f, the compiled public CLI reports a selected CUBIN object as inspection: "malformed" when an ELF kernel symbol name has 65,536 bytes followed by a valid NUL terminator. The limitation says ELF string is unterminated or exceeds the string budget.

The bounded reader examined only 65,536 bytes. This does not establish that the source string is unterminated or corrupt.

Reproduction actually run

After installing the locked dependencies and running npm run build:cached, use the repository's existing CUBIN format fixture:

import { cubinFixture } from './tests/fixtures/gpu/codeObjects.ts';
import { writeFile } from 'node:fs/promises';
await writeFile('long-name.cubin', cubinFixture({ name: 'k'.repeat(65536) }));

Run the snippet with the pinned Node 24.22.1, then:

node scripts/rea.mjs inspect-gpu-code-objects long-name.cubin --analysis kernels --detail complete --json
Name length Actual selected-object outcome Kernel rows
7 bytes complete 1
65,535 bytes partial (some long section names unknown) 1
65,536 bytes malformed 0
70,000 bytes malformed 0

A separate Python struct reader checked all declared file-backed section extents and found each symbol's exact NUL terminator inside its declared string table. A short string table with its terminator removed correctly remained malformed. All five CLI controls left their input hashes unchanged.

Expected behavior and impact

The ELF gABI string-table contract represents names as NUL-terminated byte sequences indexed within the declared table.

Retain the existing scan limit. When the scan ends while declared string-table bytes remain unexamined, report a decoder/resource limit (capacity in GPU object inspection), rather than treating the file as proven malformed. A fully examined unterminated string and an out-of-range offset must remain malformed. Preserve unrelated decoded facts and ELF export consumers.

The observed impact is misleading corruption classification for these constructed inputs. Real-world frequency is NOT_ENOUGH_INFO; this is not a claim of GPU execution, nvcc compilation, complete CUDA ABI validation, or testing on other hosts.

Analysis

Source-derived: src/native/metadata/ElfStringTable.ts uses observeElfStringTableEntry(..., 65536) and maps every truncated observation to BinaryFormatFailure("malformed"), including a bounded scan that did not reach the end of the table. CUBIN kernel decoding uses this common string reader.

Related #8883/#8882 concerns AMDGPU MessagePack container cardinality, a different decoder boundary. I read its production change and relevant ELF/export PR diffs, as well as searching current open/closed issues and PRs; I did not find a public implementation of this string-table correction.

Environment

REA source main above; Node 24.22.1; macOS 27.0.1 arm64. Synthetic, self-owned CUBIN/ELF fixtures; no target execution or mutation. AI-assisted reproduction and report.

Originally created by @xu91102 on GitHub (Nov 5, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/8952 ### Observed behavior On unmodified main `71f680d7c1aa7a45ba0325fe87b104744b0c105f`, the compiled public CLI reports a selected CUBIN object as `inspection: "malformed"` when an ELF kernel symbol name has 65,536 bytes followed by a valid NUL terminator. The limitation says `ELF string is unterminated or exceeds the string budget`. The bounded reader examined only 65,536 bytes. This does not establish that the source string is unterminated or corrupt. ### Reproduction actually run After installing the locked dependencies and running `npm run build:cached`, use the repository's existing CUBIN format fixture: ```js import { cubinFixture } from './tests/fixtures/gpu/codeObjects.ts'; import { writeFile } from 'node:fs/promises'; await writeFile('long-name.cubin', cubinFixture({ name: 'k'.repeat(65536) })); ``` Run the snippet with the pinned Node 24.22.1, then: ```sh node scripts/rea.mjs inspect-gpu-code-objects long-name.cubin --analysis kernels --detail complete --json ``` | Name length | Actual selected-object outcome | Kernel rows | | --- | --- | --- | | 7 bytes | complete | 1 | | 65,535 bytes | partial (some long section names unknown) | 1 | | 65,536 bytes | malformed | 0 | | 70,000 bytes | malformed | 0 | A separate Python `struct` reader checked all declared file-backed section extents and found each symbol's exact NUL terminator inside its declared string table. A short string table with its terminator removed correctly remained `malformed`. All five CLI controls left their input hashes unchanged. ### Expected behavior and impact The [ELF gABI string-table contract](https://gabi.xinuos.com/elf/04-strtab.html) represents names as NUL-terminated byte sequences indexed within the declared table. Retain the existing scan limit. When the scan ends while declared string-table bytes remain unexamined, report a decoder/resource limit (`capacity` in GPU object inspection), rather than treating the file as proven malformed. A fully examined unterminated string and an out-of-range offset must remain malformed. Preserve unrelated decoded facts and ELF export consumers. The observed impact is misleading corruption classification for these constructed inputs. Real-world frequency is **NOT_ENOUGH_INFO**; this is not a claim of GPU execution, nvcc compilation, complete CUDA ABI validation, or testing on other hosts. ### Analysis Source-derived: `src/native/metadata/ElfStringTable.ts` uses `observeElfStringTableEntry(..., 65536)` and maps every `truncated` observation to `BinaryFormatFailure("malformed")`, including a bounded scan that did not reach the end of the table. CUBIN kernel decoding uses this common string reader. Related #8883/#8882 concerns AMDGPU MessagePack container cardinality, a different decoder boundary. I read its production change and relevant ELF/export PR diffs, as well as searching current open/closed issues and PRs; I did not find a public implementation of this string-table correction. ### Environment REA source main above; Node 24.22.1; macOS 27.0.1 arm64. Synthetic, self-owned CUBIN/ELF fixtures; no target execution or mutation. AI-assisted reproduction and report.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7867
No description provided.