[Lldb-commits] [lldb] b571b4d - [lldb] Fix data race in UnwindTable::Initialize (#197816)
via lldb-commits
lldb-commits at lists.llvm.org
Thu May 14 17:52:52 PDT 2026
Author: Jonas Devlieghere
Date: 2026-05-14T17:52:47-07:00
New Revision: b571b4db67e718f032852dcf1c2d66ae7bbf7a8b
URL: https://github.com/llvm/llvm-project/commit/b571b4db67e718f032852dcf1c2d66ae7bbf7a8b
DIFF: https://github.com/llvm/llvm-project/commit/b571b4db67e718f032852dcf1c2d66ae7bbf7a8b.diff
LOG: [lldb] Fix data race in UnwindTable::Initialize (#197816)
UnwindTable::Initialize uses double-checked locking (DCL) against
m_scanned_all_unwind_sources, but the flag was a plain bool. The
fast-path read outside the mutex is unsynchronized with the write inside
the mutex, so concurrent first-time callers can observe partially
initialized state.
Make m_scanned_all_unwind_sources std::atomic<bool>. The default memory
ordering (seq_cst) is sufficient for the DCL pattern used here.
Found by ThreadSanitizer as part of #197792.
Added:
Modified:
lldb/include/lldb/Symbol/UnwindTable.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/UnwindTable.h b/lldb/include/lldb/Symbol/UnwindTable.h
index 1cc718efb28d6..f2741cb46dbf9 100644
--- a/lldb/include/lldb/Symbol/UnwindTable.h
+++ b/lldb/include/lldb/Symbol/UnwindTable.h
@@ -9,6 +9,7 @@
#ifndef LLDB_SYMBOL_UNWINDTABLE_H
#define LLDB_SYMBOL_UNWINDTABLE_H
+#include <atomic>
#include <map>
#include <mutex>
#include <optional>
@@ -75,11 +76,10 @@ class UnwindTable {
Module &m_module;
collection m_unwinds;
- bool m_scanned_all_unwind_sources; // true when we have looked at the
- // ObjectFile and SymbolFile for all
- // sources of unwind information; false if
- // we haven't done that yet, or one of the
- // files has been updated in the Module.
+ /// This is true when we have looked at the ObjectFile and SymbolFile for all
+ /// sources of unwind information; false if we haven't done that yet, or one
+ /// of the files has been updated in the Module.
+ std::atomic<bool> m_scanned_all_unwind_sources;
std::mutex m_mutex;
std::unique_ptr<CallFrameInfo> m_object_file_unwind_up;
More information about the lldb-commits
mailing list