Conversation
quit is in the script command table, so it is reachable from the Python binding and from the HTTP server, and it called exit(0). A host got no exception and no traceback, its finally blocks and atexit handlers never ran, buffered output was lost, and the status was 0 — so a batch job recorded success having stopped early. quit now releases the session and records the request; quitRequested() exposes it and clearQuitRequest() forgets it. The shell in app/forefire is what leaves: both the interactive loop and the HTTP listen loop check it, so a served quit[] still stops the server. executeLoop stops reading a script after one, rather than the process disappearing mid-file. currentSession.params is no longer deleted. It is the SimulationParameters singleton, owned by GetInstance() and shared with every other holder, so deleting it left GetInstance() handing out a dangling pointer. That went unnoticed only because exit() followed on the next line; without the exit it would be a use-after-free on the next parameter read. The safe topology error path called quit() too, so an internal failure terminated the host on its own, with status 0. It reports and returns error instead. The message moves to stderr and is no longer gated on commandOutputs: a returned error nobody is obliged to check should not also be silent. tests/unit/test_quit_command.cpp covers it, and the CTest entries now require doctest's closing 'Status: SUCCESS!' line. Without that a suite whose process exits mid-run reports as a pass, because ctest sees 0 and does not look for the summary that never printed — the first version of this test passed happily with exit(0) still in place. Verified with the reproduction from #160: before quit[] / AFTER quit[] / FINALLY ran / ATEXIT ran, exit 0 against the previous output, which was 'before quit[]' and a dead interpreter. Unit suite 5/5; runff KML and NetCDF match. Closes #160
This branch has not been deployed
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.
Closes #160.
@filippi, one decision for you:
Command.cpp:1125(safe-topologycatch,// TODO supersafe mode ?) used to callquit()and end the host with status 0. It now reports and returns an error, so coupled runs keep going after a safe-topology failure. If you need a hard stop there, I'll add a separate command that the Python binding does not expose.quitno longer callsexit(0). It releases the session and sets a flag (quitRequested()/clearQuitRequest()). Theapp/forefireshell reads the flag and exits, soquit[]over HTTP still stops the server.quitno longer deletescurrentSession.params. That is the sharedSimulationParameterssingleton, and without theexit()deleting it would become a use-after-free.Status: SUCCESS!line, so a test that exits early fails instead of passing.Tested: the #160 reproduction now reaches
finallyandatexit. Unit tests 5/5 (3 new).runffKML and NetCDF match.Code and description generated with Claude Opus 5, reviewed before submitting.