Skip to content

fix(codemods): SIGSEV segfault problem. reduce amount of parse() calls. Preserve ast root refe…#10503

Closed
BobrImperator wants to merge 3 commits intowarp-drive-data:mainfrom
BobrImperator:fix-segfault-attempt
Closed

fix(codemods): SIGSEV segfault problem. reduce amount of parse() calls. Preserve ast root refe…#10503
BobrImperator wants to merge 3 commits intowarp-drive-data:mainfrom
BobrImperator:fix-segfault-attempt

Conversation

@BobrImperator
Copy link
Copy Markdown
Contributor

@BobrImperator BobrImperator commented Mar 24, 2026

The problem doesn't seem to happen on small projects or when the warp-drive codemods are built directly and ran with node ~/Projects/warp-drive/packages/codemods/dist/index.js apply migrate-to-schema --config=./example-codemod.config.json

⚠️ Temporary solution:
Setting ulimit -s unlimited (Unlimited stack-size) points towards a stack overflow issue while running the codemod against large projects. The problem appears to be happening in @ast-grep/napi / treesitter
ulimit -s unlimited && pnpx @ember-data/codemods@canary apply migrate-to-schema --config=./example-codemod.config.json
ulimit -s unlimited && node~/Projects/warp-drive/packages/codemods/dist/index.js apply migrate-to-schema --config=./example-codemod.config.json

Reproductions:

  • bun
    bun ~/Projects/warp-drive/packages/codemods/dist/index.js apply migrate-to-schema --config=./example-codemod.config.json

Bun v1.3.6 (d530ed99) macOS Silicon
macOS v15.7.1
CPU: fp aes crc32 atomics
Args: "bun" "~/Projects/warp-drive/packages/codemods/dist/index.js" "apply" "migrate-to-schema" "--config=./example-codemod.config.json"
Features: Bun.stderr(2) Bun.stdin(2) Bun.stdout(2) dotenv jsc transpiler_cache tsconfig(3) tsconfig_paths(2) process_dlopen
Builtins: "bun:main" "node:assert" "node:buffer" "node:child_process" "node:events" "node:fs" "node:fs/promises" "node:module" "node:os" "node:path" "node:process" "node:stream" "node:string_decoder" "node:tty" "node:url" "node:util"
Elapsed: 10198ms | User: 9570ms | Sys: 916ms
RSS: 2.00GB | Peak: 2.00GB | Commit: 0.26GB | Faults: 62 | Machine: 51.54GB

panic(main thread): Segmentation fault at address 0x16C3E3FD0
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

  • pnpx
    pnpx @ember-data/codemods@canary apply migrate-to-schema --config=./example-codemod.config.json

pnpm: Command was killed with SIGSEGV (Segmentation fault): codemods apply migrate-to-schema --config=./example-codemod.config.json
at makeError (/Users/bobrimperator-mac/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/pnpm.cjs:15358:17)
at handlePromise (/Users/bobrimperator-mac/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/pnpm.cjs:15929:33)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.handler [as dlx] (/Users/bobrimperator-mac/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/pnpm.cjs:188580:9)
at async /Users/bobrimperator-mac/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/pnpm.cjs:199444:23
at async main (/Users/bobrimperator-mac/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/pnpm.cjs:199402:34)
at async runPnpm (/Users/bobrimperator-mac/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/pnpm.cjs:199669:5)
at async /Users/bobrimperator-mac/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/pnpm.cjs:199661:7

@BobrImperator BobrImperator changed the title fix(codemods): segfault problem. reduce amount of parse() calls. Preserve ast root refe… fix(codemods): SIGSEV segfault problem. reduce amount of parse() calls. Preserve ast root refe… Mar 24, 2026
@BobrImperator
Copy link
Copy Markdown
Contributor Author

Closing since we're able to get around this and regular users won't encounter this problem.

ulimt -s unlimited has also been documented in #10505

@BobrImperator BobrImperator deleted the fix-segfault-attempt branch March 26, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant