From 7b77505ccd05aa1b14e4b03c463ffff67ec4632e Mon Sep 17 00:00:00 2001 From: Shashvat Prabhu Date: Wed, 10 Jun 2026 16:00:24 +0530 Subject: [PATCH] Fix data race on V3TSP edge IDs between parallel sorts (#7194) --- docs/CONTRIBUTORS | 1 + src/V3TSP.cpp | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 880b5608a..a79e61cd1 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -325,3 +325,4 @@ Yogish Sekhar 24bit-xjkp Zubin Jain Muzaffer Kal +Shashvat Prabhu diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index 4244a5676..a9edd2dde 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -41,8 +41,6 @@ VL_DEFINE_DEBUG_FUNCTIONS; // Support classes namespace V3TSP { -static uint32_t s_edgeIdNext = 0; - static void selfTestStates(); static void selfTestString(); } // namespace V3TSP @@ -77,6 +75,7 @@ public: // MEMBERS std::unordered_map m_vertices; // T_Key to Vertex lookup map + uint32_t m_edgeIdNext = 0; // Next edge ID; IDs need only be unique within this graph // CONSTRUCTORS TspGraphTmpl() @@ -105,7 +104,7 @@ public: // The only time we may create duplicate edges is when // combining the MST with the perfect-matched pairs, // and in that case, we want to permit duplicate edges. - const uint32_t edgeId = ++V3TSP::s_edgeIdNext; + const uint32_t edgeId = ++m_edgeIdNext; // We want to be able to compare edges quickly for a total // ordering, so pre-compute a sorting key and store it in