Skip to content

Fix crash and data loss in convergence output on failed runs - #7267

Draft
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:fix-convergence-output-crash
Draft

Fix crash and data loss in convergence output on failed runs#7267
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:fix-convergence-output-crash

Conversation

@hnil

@hnil hnil commented Aug 2, 2026

Copy link
Copy Markdown
Member

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

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.
@hnil
hnil requested a review from bska August 4, 2026 12:46
@hnil hnil added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant