[Lldb-commits] [lldb] 0b8c8ed - [lldb] Fix use-after-free in SBMutexTest (#133840)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 31 19:36:09 PDT 2025
Author: Jonas Devlieghere
Date: 2025-03-31T19:36:05-07:00
New Revision: 0b8c8ed04211dae629811f24e6033e5c2185508f
URL: https://github.com/llvm/llvm-project/commit/0b8c8ed04211dae629811f24e6033e5c2185508f
DIFF: https://github.com/llvm/llvm-project/commit/0b8c8ed04211dae629811f24e6033e5c2185508f.diff
LOG: [lldb] Fix use-after-free in SBMutexTest (#133840)
The `locked` variable can be accessed from the asynchronous thread until
the call to f.wait() completes. However, the variable is scoped in a
lexical block that ends before that, leading to a use-after-free.
Added:
Modified:
lldb/unittests/API/SBMutexTest.cpp
Removed:
################################################################################
diff --git a/lldb/unittests/API/SBMutexTest.cpp b/lldb/unittests/API/SBMutexTest.cpp
index 0b888c2725aa9..aafad59d58c17 100644
--- a/lldb/unittests/API/SBMutexTest.cpp
+++ b/lldb/unittests/API/SBMutexTest.cpp
@@ -32,10 +32,9 @@ class SBMutexTest : public testing::Test {
TEST_F(SBMutexTest, LockTest) {
lldb::SBTarget target = debugger.GetDummyTarget();
-
+ std::atomic<bool> locked = false;
std::future<void> f;
{
- std::atomic<bool> locked = false;
lldb::SBMutex lock = target.GetAPIMutex();
std::lock_guard<lldb::SBMutex> lock_guard(lock);
ASSERT_FALSE(locked.exchange(true));
More information about the lldb-commits
mailing list