fix(leak): unhang dump_verify_io_fork_crash under leaks --atExit

dump_verify_io_fork_crash_uncommitted_discarded used bare
waitpid(pid, &status, 0), which never returns when `leaks --atExit` (macOS)
SIGSTOPs the forked child during heap inspection — the identical hang b336466
fixed in test_store_bulk.c (bulk_crash_recovery) and src/foundation/compat_fs.c
(cbm_exec_no_shell). This test was missed by that earlier fix.

Replace the bare waitpid with the WUNTRACED+SIGCONT loop that mirrors
test_store_bulk.c: on WIFSTOPPED, kill(child, SIGCONT) so leaks can finish
inspecting and the child proceeds to _exit(). Add #include <signal.h> for kill().

Unblocks `make test-leak` past this test (the run previously hung here
indefinitely).

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
This commit is contained in:
Andrew Hundt
2026-06-24 17:03:07 -04:00
parent d85f5958fc
commit ec206caa4b
+13 -1
View File
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <store/store.h>
#ifndef _WIN32
#include <sys/wait.h>
@@ -153,7 +154,18 @@ TEST(dump_verify_io_fork_crash_uncommitted_discarded) {
}
int status = 0;
ASSERT_TRUE(waitpid(pid, &status, 0) == pid);
/* Robust wait: leaks --atExit on macOS temporarily SIGSTOPs forked children
* during heap inspection; WUNTRACED lets us detect the stop and SIGCONT so
* the child proceeds to _exit(). Mirrors test_store_bulk.c (see b336466). */
for (;;) {
pid_t r = waitpid(pid, &status, WUNTRACED);
ASSERT_TRUE(r == pid);
if (WIFSTOPPED(status)) {
kill(pid, SIGCONT);
continue;
}
break;
}
/* WAL recovery discards the child's uncommitted frames: only the baseline
* survives, so persisted (60) falls far short of the dump intent (5060). */