From ed91ab5d542fb09559ff9b615a961d3670c1d4ee Mon Sep 17 00:00:00 2001 From: Junhyun Shim Date: Tue, 14 Jun 2022 12:09:34 +0200 Subject: [PATCH] Work around flow trace's data race bug (#7237) * Work around flow trace's data race bug BaseTraceEvent::setNetworkThread() and flushTraceFile[()|Void()] has a long-standing race condition for traceEventThrottlerCache global when flushTraceFileVoid() is not called from the network thread. This race dates back to 2017 (commit hash 80e5fecfe2), so before the race itself is fixed, work around the problem. * Remove call to flushTraceFileVoid() from MkCertCli * Apply clang format --- flow/MkCertCli.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/flow/MkCertCli.cpp b/flow/MkCertCli.cpp index 5369fee028..29bb70ebb4 100644 --- a/flow/MkCertCli.cpp +++ b/flow/MkCertCli.cpp @@ -278,14 +278,11 @@ int main(int argc, char** argv) { Error::init(); g_network = newNet2(TLSConfig()); openTraceFile(NetworkAddress(), 10 << 20, 10 << 20, ".", "mkcert"); - auto thread = std::thread([]() { - TraceEvent::setNetworkThread(); - g_network->run(); - }); + auto thread = std::thread([]() { g_network->run(); }); auto cleanUpGuard = ScopeExit([&thread]() { - flushTraceFileVoid(); g_network->stop(); thread.join(); + closeTraceFile(); }); serverArgs.transformPathToAbs();