Skip to content

Commit 4568a62

Browse files
itamar8910awesomekling
authored andcommitted
Thread: Set m_blocker to null in Thread::unblock()
Before this commit, m_blocker was only set to null in Thread::block, after the thread has been unblocked. Starting with this commit, m_blocker is also set to null in Thread::unblock. This change will allow us to implement a missing feature of the PT_TRACE command of the ptrace syscall - stopping the traced thread when it exits the execve syscall. That feature will be implemented by sending a blocking SIGSTOP to the traced thread after it has executed the execve logic and before it starts executing the new program in userspace. However, since Process::exec arranges the tss to return to userspace (the so-called "yield-teleport"), the code in Thread::block that should be run after the thread unblocks, and sets m_blocker to null, never actually runs. Setting m_blocker to null in Thread::unblock allows us to avoid an incorrect state where the thread is in a Running state but conatins a pointer to a Blocker.
1 parent b306ac9 commit 4568a62

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Kernel/Thread.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ Thread::~Thread()
163163

164164
void Thread::unblock()
165165
{
166+
m_blocker = nullptr;
166167
if (current == this) {
167168
if (m_should_die)
168169
set_state(Thread::Dying);

0 commit comments

Comments
 (0)