From ec206caa4b217fc8c272b697d976bc50fb4a59fc Mon Sep 17 00:00:00 2001 From: Andrew Hundt Date: Wed, 24 Jun 2026 17:03:07 -0400 Subject: [PATCH] fix(leak): unhang dump_verify_io_fork_crash under leaks --atExit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 for kill(). Unblocks `make test-leak` past this test (the run previously hung here indefinitely). Signed-off-by: Andrew Hundt --- tests/test_dump_verify_io.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_dump_verify_io.c b/tests/test_dump_verify_io.c index 5b0b97f75..ae4fb74ac 100644 --- a/tests/test_dump_verify_io.c +++ b/tests/test_dump_verify_io.c @@ -16,6 +16,7 @@ #include #include +#include #include #ifndef _WIN32 #include @@ -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). */