mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-21 17:16:52 +00:00
[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.
This commit is contained in:
parent
b2d272ccfb
commit
0b8c8ed042
@ -32,10 +32,9 @@ protected:
|
||||
|
||||
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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user