Skip to content

Report an astgen run that fails, and keep the files it finished - #227

Merged
prabhu merged 1 commit into
mainfrom
fix/astgen-failure-reported
Oct 26, 2026
Merged

prabhu merged 1 commit into
mainfrom
fix/astgen-failure-reported

Conversation

@prabhu

@prabhu prabhu commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

When astgen fails, AstGenRunner throws the result away without a word and hands on no files. A project astgen ran out of memory on came out as an atom with one file and no methods, and nothing told the user why reachables found no flows.

astgen writes each file's AST as soon as it finishes it, so the files written before a failure are sound. The runner now keeps them, and prints on stderr that astgen failed, how many files the atom holds, and astgen's last few lines (the V8 stack frames are dropped). It uses stderr because atom ships slf4j-nop, so anything chen sends to its logger never appears. CdxPass and ChennaiTagsPass report their problems on stderr for the same reason. A failed run still isn't stored in the parse cache, as before.

I checked this against the astgen crash it came from. The globally installed astgen 4.5.1 runs out of memory on node-express-realworld-example-app. With this change atom reports:

astgen failed on …/node-express-realworld-example-app, so the atom holds only the 7 files it finished: … FATAL ERROR: Ineffective mark-compacts near heap limit …

The atom then has 89 methods and 234 tags, instead of nothing. AppThreat/atom-parsetools#25 fixes that particular crash.

jssrc2cpg (673) and x2cpg (141) pass. There's no unit test, because the runner calls astgen from PATH and the forked test JVM has no way to substitute a failing one.

AstGenRunner dropped a failed astgen run without a word and handed on no
files, so a project astgen ran out of memory on came out as an atom with
one file and no methods. astgen writes each file's AST as it finishes it,
so the files before the failure are sound: keep them, and say on stderr
that astgen failed and how many files the atom holds, with astgen's last
words. stderr because atom does not print chen's log.

Signed-off-by: Team AppThreat <cloud@appthreat.com>
@prabhu prabhu added bug Something isn't working jssrc crash ai-auto A person set the task, and AI agents carried it through to completion labels Oct 26, 2026
@prabhu
prabhu enabled auto-merge October 26, 2026 03:24
@prabhu
prabhu added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit a2bec69 Oct 26, 2026
7 checks passed
@prabhu
prabhu deleted the fix/astgen-failure-reported branch October 26, 2026 03:55
@prabhu prabhu added this to the v4.0.0 Pelorus milestone Oct 28, 2026
@prabhu prabhu moved this to Done in AppThreat roadmap Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-auto A person set the task, and AI agents carried it through to completion bug Something isn't working crash jssrc

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant