Fix crash and data loss in convergence output on failed runs - #7267
Draft
hnil wants to merge 1 commit into
Draft
Conversation
When a simulation aborted before completing any report step, the convergence output thread crashed with SIGSEGV: the end-of-stream marker enqueued by signalLastOutputRequest() is a request with an empty reports vector, and writeConvergenceHeader() unconditionally dereferenced reports.front() of the first request to lay out the metric columns. Three related problems fixed: - The shutdown sentinel is now an explicit isFinal flag on OutputRequest instead of "reports is empty". An ordinary request with no convergence reports (a step that aborted before its first convergence check) was previously indistinguishable from the sentinel and silently shut the writer thread down mid-run. - The header is laid out from the first request that actually carries a convergence report, and requests without reports are skipped instead of dereferenced. - The step reports accumulated up to the point of failure are now flushed to the INFOITER file before the writer thread is joined, and endThread() is idempotent (also called from a new SimulatorConvergenceOutput destructor as a backstop). Previously a failed run left a zero-byte INFOITER -- discarding the convergence history of exactly the runs whose convergence history is most needed. Reproducer: any deck that fails in its first report step with --output-extra-convergence-info=steps,iterations, e.g. opm-tests wconprod/WCONPROD-01.DATA (crash) or spe02/SPE02-SPIDER-01.DATA (zero-byte INFOITER); both now exit cleanly with diagnostics on disk. Healthy runs produce byte-identical INFOITER content.
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.
With --output-extra-convergence-info, a run that aborts before completing any report step segfaulted in the output thread: the shutdown sentinel is a request with an empty reports vector, and writeConvergenceHeader dereferenced reports.front(). Fixed by an explicit isFinal flag (an ordinary empty request also silently shut the thread down mid-run), skipping report-less requests, and flushing pending step reports before joining — so failed runs now leave their convergence history in INFOITER instead of a zero-byte file.
Reproducers: opm-tests wconprod/WCONPROD-01.DATA (crash), spe02/SPE02-SPIDER-01.DATA (empty INFOITER); both 3 s. Healthy runs produce identical output; regression suite unchanged.
🤖 Generated with Claude Code