Repository navigation
Supervise the atom runtime so it never outlives its caller - #267
Merged
Merged
Conversation
The dispatcher ran the runtime (the native binary or java) with spawnSync, so a caller's timeout killed the dispatcher and left the runtime running, adopted by init with its heap (cdxgen/cdxgen#4419). The dispatcher now: - forwards SIGINT/SIGTERM/SIGHUP/SIGQUIT to the runtime and waits for it; - enforces ATOM_TIMEOUT itself, SIGTERM then SIGKILL after ATOM_KILL_GRACE_MS (default 10 s), and exits with status 124; - stops the runtime when the process named by ATOM_PARENT_PID goes away, and passes its own pid to the runtime the same way; - reports a runtime killed by a signal as 128 + signal number; - hands leading -XX:/-Xmx runtime options to java on the jar provider, so callers can bound the heap the same way for both providers; - keeps a caller-set PHP_PARSER_BIN instead of overwriting it.
When ATOM_PARENT_PID names a supervisor, a daemon thread checks once a second and atom exits once that process has exited or atom has been re-parented. This covers a dispatcher killed with SIGKILL, which cannot be forwarded. A shutdown hook stops the helper processes atom started (astgen, php-parse, atom-tools), so SIGTERM, a timeout or the watchdog does not leave those behind.
A rerun into the same path with fewer flows left the earlier run's higher numbered <base>_N.json chunks in place, and consumers that read chunks until the first gap, or glob them, picked up stale flows.
A run stopped while writing (a timeout, a kill) left a truncated JSON file at the final path, which consumers took for a finished slice and failed to parse. Reachables chunks, the usages and data-flow slices and the empty reachables result are now written to a temporary sibling and renamed into place once complete.
The first SIGINT/SIGTERM is relayed so atom can stop cleanly. A runtime that ignored it kept the dispatcher waiting with no way out short of killing the dispatcher itself; a second signal now kills the runtime.
A run killed between writing a reachables file and renaming it into place left its hidden temporary file behind; the next run's chunk cleanup now removes it too.
This was referenced Oct 1, 2026
better-files' list(filter) walks the whole tree. With the slices file in /tmp it reached unreadable systemd-private directories and failed the reachables run, and in a project directory it would delete same-named chunks in subdirectories. Clean-up is best effort, so a directory that cannot be listed no longer fails the run.
Java takes user.home from the passwd entry (/root), not from HOME, so sbt looked in /root/.ivy2/local and missed the chen that the chen-from-main step publishes into the Ivy directory mounted at /tmp/home/.ivy2.
1.8.0 stops a helper and the processes it started once its supervisor is gone.
The npm-publish job was the only sbt job without the temporary chen-from-main step, so it could not resolve chen 4.0.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
atom no longer outlives the process that started it. Part of cdxgen/cdxgen#4419.
The npm dispatcher ran the runtime (native binary or java) with
spawnSync. When a caller's timeout killed the dispatcher, the runtime was reparented to init and kept its heap.Dispatcher (
wrapper/nodejs):ATOM_TIMEOUT: SIGTERM, then SIGKILL afterATOM_KILL_GRACE_MS, then exits 124.ATOM_PARENT_PID(cdxgen sets its own pid) is gone.-XX:/-Xm*options to java on the jar provider.PHP_PARSER_BIN.atom:
@appthreat/atom-parsetools1.8.0 (Stop a helper and its children when its supervisor is gone atom-parsetools#14).CI: the musl build container now runs sbt with
user.homeset to the mounted home, so it finds the chen thatchen-from-mainpublishes (this job failed on earlier PRs too).Testing
ProcessSupervisionTests,SliceFilesTestsandReachableChunkFilesTests;sbt testpasses.Related: cdxgen/cdxgen#4433 (cdxgen side), AppThreat/chen#189, AppThreat/atom-parsetools#14.