Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Large LLVM metadata tables crash compilation with a stack overflow

Aperta
#2,394 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@MathurAditya724 ci sta già lavorando.

Dal 27/10/2026.

  • #2401 di @MathurAditya724 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
compilers

Direzione di ricerca

Start with out.push(...emitter.fieldAliasMetadata()) in emitModuleParts in packages/compiler/src/backend/llvm/emit-module.ts, in both the executable and library branches. Run the repro script from the issue, which calls LlEmitter.emitParts with 100,000 field aliases. Done means both branches append each line in order without spreading arguments, and the repro no longer throws. Pull request #2401 already proposes this fix, so check its state before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

We are experimenting with compiling a complete Node.js CLI and its existing dependencies with scriptc, keeping its logging, terminal UI and persistence. While investigating large builds, we found that assembling a sufficiently large LLVM metadata table crashes the compiler.

The metadata fits in memory. The crash happens because the compiler passes every metadata line as a separate argument to one JavaScript push call. The reduced stress test below demonstrates this without needing the full CLI.

Reproduction

After building the compiler workspace, save this as repro.mjs in the repository root:

import { LlEmitter } from "./packages/compiler/dist/backend/llvm/emitter.js";
import { VOID } from "./packages/compiler/dist/ir/ir.js";

const loc = { file: "large-metadata.ts", start: 0, end: 0 };
const mod = {
  irVersion: 17,
  sourceFile: loc.file,
  entry: "main",
  functions: [{ name: "main", params: [], returnType: VOID,
    locals: [], body: [], loc }],
};
const emitter = new LlEmitter(mod, {});
for (let i = 0; i < 100_000; i++) {
  emitter.fieldAliasTags.set(`field.${i}`, 2 + i * 2);
}
console.log(emitter.fieldAliasMetadata().length); // 200001
emitter.emitParts();
$ node repro.mjs
200001
RangeError: Maximum call stack size exceeded

The stack points to emitModuleParts in packages/compiler/src/backend/llvm/emit-module.ts, at out.push(...emitter.fieldAliasMetadata()). The executable and library branches both contain this append. Separate regressions reproduce the same failure in each branch. A ten-tag control succeeds; the large RC-tail append now also succeeds because that neighboring path already iterates over its lines.

Expected behavior

Emitting a metadata table should not depend on the JavaScript engine's function-argument limit. Preserve every line and its order, for both executable and library modules, without changing ordinary emitted LLVM.

Scope

The existing iterative append pattern is sufficient for these two sites. No runtime ABI, metadata format, type inference or code-generation policy needs to change.

This is distinct from #1796 and #1575, which concern appending WASM FunctionTranslator body lines. This reproduction contains no WASM module and fails in LLVM module assembly instead.

Proposed fix and regression tests: #2401.

Tested environment

Reproduced with a source build from scriptc’s main development branch on macOS arm64, using Node 24.22.0 and matching native compiler/runtime packages. The source build reports version 0.4.5. The original gap was also checked against later main changes before opening the linked PR.

Source revision used for the reproduction.

Lingua principale
TypeScript
Stelle
6.4k
Fork
201
Merge medio
6h 56m
PR unite (30g)
916

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel-labs/scriptc

Tutte le issue di vercel-labs/scriptc

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.