From 4cf34026e7b408e52094cfbd449e4e82cdab5b3a Mon Sep 17 00:00:00 2001 From: TapTap Date: Sun, 6 Sep 2026 16:27:54 +0200 Subject: [PATCH] test: drop racy queued_bytes==0 assert in byte-budget test After the writer releases bytes, the blocked enqueuer may already have admitted the next payload, so the transient queued_bytes==0 read is scheduling-dependent (lost the race under ASan). The post-join state (covers unblocking + budget re-limit) is deterministic. --- tests/test_multiprocessing.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_multiprocessing.c b/tests/test_multiprocessing.c index a12b2ee..fb0241d 100644 --- a/tests/test_multiprocessing.c +++ b/tests/test_multiprocessing.c @@ -309,13 +309,14 @@ static void test_receiver_enqueue_byte_budget() { EXPECT_FALSE(atomic_load(&done)); EXPECT_EQ_INT((int)ctx->queued_bytes, 2000); /* budget still honored */ - /* Simulate the disk writer: dequeue + destroy + release the first file. */ + /* Simulate the disk writer: dequeue + destroy + release the first file. + Releasing bytes unblocks the waiting enqueuer, which then admits the + second payload, so only the post-join state (below) is deterministic. */ File* drained = queue_dequeue_multithreaded(q, &ctx->mutex, &ctx->condition_not_empty, &ctx->condition_not_full, &ctx->receiver_done); EXPECT_NOT_NULL(drained); file_destroy(drained); pipeline_context_receiver_note_bytes_released(ctx, 2000); - EXPECT_EQ_INT((int)ctx->queued_bytes, 0); EXPECT_EQ_INT(thrd_join(enqueuer, NULL), thrd_success); EXPECT_TRUE(atomic_load(&done));