Native CLI (scriptc.exe) segfaults on a large program that the same release compiles under Node

Open
#3,595 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
nodejs, typescript
Domain
compilers

Research direction

The crash is in the natively compiled CLI bin/scriptc.exe during scriptc coverage and scriptc build, with no reproduction because the app source is private. The entry point to read is packages/cli/src/main.ts, which the reporter ran under Node as a working comparison. Start by building a symbolized CLI and reproducing the crash on a large entry. Done means the native CLI finishes coverage on that entry without SIGSEGV and matches the Node output.

Written by the indexing model from the issue text.

Description

The native CLI that the scriptc npm package installs (bin/scriptc.exe, linux-x64-gnu) crashes with SIGSEGV (exit 139) on a large program, before it prints any report. The same release's compiler, run as JavaScript under Node, analyzes and builds the same program without errors.

Environment

  • scriptc 0.4.12 from npm (scriptc with @scriptc/cli-linux-x64-gnu); 0.4.11 from npm crashes the same way.
  • Linux 6.8.0 x86_64, glibc 2.39.
  • Node v24.22.0 for the JavaScript run.

What happens

scriptc coverage crashes with exit 139 and no report:

$ scriptc coverage src/main.ts --print=diagnostics --fail-on=blockers
Segmentation fault (core dumped)

scriptc build of the same entry, with the app's FFI manifest, crashes the same way.

The entry is a terminal app of about 25,000 statements: a TypeScript app on light's native packages. The coverage crash doesn't need its FFI manifest. Smaller entries from the same workspace (41 of light's own coverage entries and 118 of the app's test entries) pass scriptc coverage with the native CLI.

The crash doesn't depend on the stack limit: it also happens under ulimit -s unlimited. The binary is stripped, and gdb shows a shallow stack, so this isn't deep recursion:

Thread 1 "scriptc.exe" received signal SIGSEGV, Segmentation fault.
0x0000000005e3ec38 in ?? ()
#0  0x0000000005e3ec38 in ?? ()
#1  0x0000000002f9e1a7 in ?? ()
#2  0x0000000002ef6c6e in ?? ()
#3  0x0000000002f792c8 in ?? ()
#4  0x00000000040a0037 in ?? ()
#5  0x00000000040a01fc in ?? ()
#6  0x0000000004283b49 in ?? ()
#7  0x0000000004c778af in ?? ()
#8  0x00000000037048ba in ?? ()
#9  0x00000000044b644d in ?? ()
#10 0x0000000003ae2a4f in ?? ()
#11 0x0000000002f8e6ac in ?? ()
#12 0x000000000299830d in ?? ()
#13 0x000000000298cbb1 in ?? ()
#14 __libc_start_call_main (main=0x298c880, argc=4, ...)

What works

The same program compiles when the compiler runs under Node:

  • @scriptc/compiler 0.4.12 from npm, driven by a copy of packages/cli/src/main.ts at v0.4.12: scriptc coverage reports the entry fully static, and scriptc build produces a working executable.
  • A source build of v0.4.11 plus #3504, run with node packages/cli/dist/main.js: scriptc coverage reports 24,873 statements, 100% static.

So the failure seems specific to the natively compiled CLI rather than to the compiler's handling of the program.

Reproducing

The app's sources aren't public yet. I can try to reduce it to a standalone reproduction, or run a build of the CLI with symbols, or with whatever diagnostics would help, if you can point me to one.

Dominant language
TypeScript
Stars
6.7k
Forks
229
Avg merge
14h 29m
Merged PRs (30d)
787

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel-labs/scriptc

All issues in vercel-labs/scriptc

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.