Repository navigation
Description
Summary. A review of a copy of pstack/skills/statechart/scripts at ca782ed found seven defects. None of them is a security defect. Most of them are in the cleanup paths, where a stop or a failure can leave a process or a folder behind.
Items.
kill.ts:12,process.kill(-pid, "SIGKILL"), andjanitor.ts:12: on POSIX, the parent and the janitor kill the process group by its number also after the worker exits. The OS can give that number to a new process group.kill.ts:6startstaskkill /pid <pid> /t /fand ignores its result. When the stop fails on Windows, the caller can wait until the worker ends.backends/mermaid.ts:100and:123:drawnEdgesjoins the entry arrows into one composite state only when they have the same source (wayIn). When it joins two or more arrows, it drops the label of the outer arrow, also when the labels are equal. The labels go to the inner arrows.run.ts:243,sanyErrors, andrun.ts:314-324: when the XML export of SANY exits with an error code (not a launch error), the script runs SANY again. It reads the full log into memory before it keeps 40 lines, and it does not check the exit code of that second run.statechart.ts:153and:157-158: the entry moves the output and printsWrote <out>before thefinallyblock removestmp. A long lock ontmpthen gives exit code 2 with a chart on disk.statechart.ts:157-158: thefinallyblock removes the stage folder first. When that remove throws, the script does not removetmp.run.ts:104,joined(): it opens one file descriptor for each log and never closes it.
Suggested fixes. Item 1: kill the group only while the worker runs, or keep a handle to the process tree. Item 2: read the exit code of taskkill, and report a failure. Item 3: keep the outer label when the joined arrows have one label. Item 4: read the second log with a size limit, and check its exit code.
Items 5 and 6: remove tmp before the Wrote line. Give each remove of the finally block its own try. Then a failed remove of the stage folder does not skip the remove of tmp. Item 7: close each descriptor after the read.
Related. #1170 asks for taskkill on Windows. Item 2 is a different defect: kill.ts now starts taskkill, but it ignores the result.
Scope. We found these items in reviews of our copy. We did not test other scripts of the repository. On 2026-11-25 no commit after ca782ed changed pstack/skills/statechart/scripts/ (newest commit 41e4009).
Activity
anoop16-web commentedon Nov 25, 2026
Fix with java script