Skip to content

Commit

Permalink
Avoid use-after-free of m_cvWakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber authored and j-stephan committed Dec 9, 2022
1 parent ccb8683 commit 3308d8b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/alpaka/core/ConcurrentExecPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ namespace alpaka::core
m_bDetachedFlag = true;
else
{
{
std::lock_guard<TMutex> lock(this->m_mtxWakeup);
m_bDetachedFlag = true;
}
std::lock_guard<TMutex> lock(this->m_mtxWakeup);
m_bDetachedFlag = true;
// we need to notify during the lock, because setting m_bDetachedFlag to true, allows another
// thread to delete this and thus destroy m_cvWakeup.
this->m_cvWakeup.notify_one();
}
}
Expand Down Expand Up @@ -355,7 +355,8 @@ namespace alpaka::core
if(self)
{
// Pool was detached and is idle, stop and delete
lock.unlock();
lock.unlock(); // TODO(bgruber): I guess we unlock here so the mutex is not locked when
// the dtor of self runs, which also tries to lock?
return;
}

Expand Down

0 comments on commit 3308d8b

Please sign in to comment.