From b180d91b1eafe9f14e2e6fcaa4c2ca7cb11194dd Mon Sep 17 00:00:00 2001 From: "andrey.bychkov" Date: Mon, 10 Aug 2026 15:48:24 +0300 Subject: [PATCH] fix(pibasetransfer): make shared flags std::atomic to eliminate data race Flags break_, is_sending, is_receiving, is_pause are accessed from both the send thread (send_process) and the read thread (received) without synchronization. Plain bool reads/writes from multiple threads is undefined behavior per C++ standard. Convert to std::atomic with proper initializers. --- libs/main/io_utils/pibasetransfer.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/main/io_utils/pibasetransfer.h b/libs/main/io_utils/pibasetransfer.h index bf46fda3..901fe936 100644 --- a/libs/main/io_utils/pibasetransfer.h +++ b/libs/main/io_utils/pibasetransfer.h @@ -28,6 +28,8 @@ #include "picrc.h" #include "pidiagnostics.h" +#include + //! \~\ingroup IO-Utils //! \~\brief @@ -301,7 +303,7 @@ protected: bool send_process(); uint packet_header_size, part_header_size; - bool break_, is_sending, is_receiving, is_pause; + std::atomic break_{true}, is_sending{false}, is_receiving{false}, is_pause{false}; PIString state_string; llong bytes_all, bytes_cur;