From 2f91af7352c36467ac5f2da2f3430a55e60360f2 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Fri, 3 Jul 2026 17:11:46 +0200 Subject: [PATCH] test: gate DisconnectMidWrite test on writer connection to fix race TCPImageCommTest_DisconnectMidWrite_NoHang launched the sender before the puller's connection was accepted by the pusher's background accept thread. When StartDataCollection ran first it threw "No writers connected", which escaped the sender lambda (re-thrown by sender.get()) and starved the receiver thread's PollImage, whose REQUIRE failure aborted with SIGABRT. Wait for GetConnectedWriters()==1 before starting, matching every other test in the file. Co-Authored-By: Claude Fable 5 --- tests/TCPImagePusherTest.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/TCPImagePusherTest.cpp b/tests/TCPImagePusherTest.cpp index 9b04c63d..021b49ab 100644 --- a/tests/TCPImagePusherTest.cpp +++ b/tests/TCPImagePusherTest.cpp @@ -510,6 +510,11 @@ TEST_CASE("TCPImageCommTest_DisconnectMidWrite_NoHang", "[TCP]") { TCPStreamPusher pusher("tcp://127.0.0.1:*", 1); TCPImagePuller puller(pusher.GetAddress()[0], 64 * 1024 * 1024); + // Wait for the puller to connect before starting data collection + for (int attempt = 0; attempt < 100 && pusher.GetConnectedWriters() < 1; ++attempt) + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + REQUIRE(pusher.GetConnectedWriters() == 1); + std::thread receiver([&] { bool disconnected = false; while (!disconnected) {