diff --git a/src/controller/testsuite/test_persist_truncate.c b/src/controller/testsuite/test_persist_truncate.c index 56750a1..4125700 100644 --- a/src/controller/testsuite/test_persist_truncate.c +++ b/src/controller/testsuite/test_persist_truncate.c @@ -335,6 +335,16 @@ static void test_truncate_above_resolves_pending_continuations_as_failed(void) "truncation -- only entries strictly above the new tail were " "removed from the log"); + /* bug-1452: persist_stop() MUST run before commit_engine_fini() -- the + * fsync_worker flusher thread is still live here and can be mid-flight + * calling the durable-advance callback (commit.c's fsync_worker -> + * commit_on_durable_advance -> commit_advance_locked) with NO lock held. + * commit_engine_fini() destroys ce->lock/ce->cond and nulls ce->p; racing + * that against a still-running flusher lets commit_advance_locked observe + * ce->p go NULL between its own guard check and its dereference -> SEGV. + * persist_stop() joins the flusher thread first, so by the time + * commit_engine_fini() runs, nothing can call back into ce. */ + persist_stop(p); commit_engine_fini(&ce); teardown_persist(p); printf("test_truncate_above_resolves_pending_continuations_as_failed: PASS\n"); @@ -371,6 +381,9 @@ static void test_truncate_noop_does_not_resolve_pending_continuations(void) "a no-op truncate (nothing above cutoff_lsn) must not resolve any " "pending continuation"); + /* bug-1452: stop the flusher thread before tearing down ce -- see the + * comment in test_truncate_above_resolves_pending_continuations_as_failed. */ + persist_stop(p); commit_engine_fini(&ce); teardown_persist(p); printf("test_truncate_noop_does_not_resolve_pending_continuations: PASS\n"); @@ -482,6 +495,9 @@ static void test_truncate_concurrent_burst_resolves_above_cutoff_exactly_once(vo "only the above-cutoff admission slots are released by truncation; " "the below-cutoff ones remain pending"); + /* bug-1452: stop the flusher thread before tearing down ce -- see the + * comment in test_truncate_above_resolves_pending_continuations_as_failed. */ + persist_stop(p); commit_engine_fini(&ce); teardown_persist(p); printf("test_truncate_concurrent_burst_resolves_above_cutoff_exactly_once: "