Large LLVM metadata tables crash compilation with a stack overflow
I maintainer di solito rispondono entro 1 giorno
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.
- Lingua principale
- TypeScript
- Stelle
- 6.4k
- Fork
- 201
- Merge medio
- 6h 56m
- PR unite (30g)
- 916
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel-labs/scriptc
-
util.format %o passes the wrong showHidden flag to custom inspectorsForse già presa @MathurAditya724 l’ha presa oggi. Aperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 35/100
vercel-labs/scriptc#2571 ·
I maintainer di solito rispondono entro 1 giorno
-
process.cwd.name keeps the main-thread name inside WorkersForse già presa @MathurAditya724 l’ha presa 1 giorno fa. Aperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 35/100
vercel-labs/scriptc#2557 ·
I maintainer di solito rispondono entro 1 giorno
-
SC2003 'string | undefined' when a method returning an element of its array field is used inlineAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
vercel-labs/scriptc#2400 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
vercel-labs/scriptc#2399 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
vercel-labs/scriptc#2209 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel-labs/scriptc
Issue simili
-
bug ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
PhyberApex/kuroshiro#1687 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
microsoft/monaco-editor#5563 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
awslabs/visual-asset-management-system#937 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100