Skip to content

Fail fast if the template process dies during dmtcp_restart#7

Open
gc00 wants to merge 1 commit into
mainfrom
fail-fast-on-template-death
Open

Fail fast if the template process dies during dmtcp_restart#7
gc00 wants to merge 1 commit into
mainfrom
fail-fast-on-template-death

Conversation

@gc00

@gc00 gc00 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

In fork_process_source.cpp: "The template process ... was not synchronized with correctly:", it's possible that mtcp_restart crashed before the template process could post. (See the comment in the code.) The result was silent hanging, instead of registering the crash of mtcp_restart. This PR fixes that. It was helpful in development to support TSAN.

When model checking from a checkpoint, multithreaded_fork_process_source
launched dmtcp_restart and then blocked on the readiness semaphore via a
plain sig_semwait. If the restarted template process died before signaling
readiness -- a corrupt or incompatible checkpoint, or any crash during
restore -- mcmini hung forever with no diagnostic: SIGCHLD is not
guaranteed to reach us (dmtcp_restart may reparent the restored process),
so the semaphore was never posted and the wait never returned.

Poll the readiness semaphore with a 1s timeout and, whenever it hasn't been
posted, actively check whether the template process is still alive with
waitid(P_PID, ..., WEXITED|WNOHANG|WNOWAIT). If it died, throw
process_creation_exception with a clear message instead of blocking. WNOWAIT
peeks without reaping, so the process handle's destructor is unaffected.
The liveness check also runs after a successful acquire, because the SIGCHLD
handler posts the same semaphore on child death -- so a post alone does not
imply the template stabilized.

This is a general robustness fix (independent of TSAN/DMTCP specifics): the
classic fork-from-main path already detects template death via SIGCHLD; the
restart path did not. It converts every restart failure from a silent hang
into a surfaced error.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gc00 gc00 requested review from aayushi363 and maxwellpirtle July 1, 2026 21:26
@gc00 gc00 added the bug Something isn't working label Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant