Skip to content

Commit

Permalink
fix modify after free crash
Browse files Browse the repository at this point in the history
mThreadHandle must not be reset before the run method has finished
  • Loading branch information
ernstblechaPT committed Jul 24, 2024
1 parent 23d49a0 commit 59cd522
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/arch/threadbase.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ template <typename TThreadHandle, TThreadHandle nullHandle, typename ThreadDelet
void CThreadBase<TThreadHandle, nullHandle, ThreadDeletePolicy>::stop() {
if(nullHandle != mThreadHandle){
setAlive(false);
mThreadHandle = nullHandle; //indicate that thread is in shutdownmode
}
}

Expand Down Expand Up @@ -75,6 +74,7 @@ void CThreadBase<TThreadHandle, nullHandle, ThreadDeletePolicy>::runThread(CThre
paThread->setAlive(true);
paThread->run();
paThread->setAlive(false);
paThread->mThreadHandle = nullHandle;
paThread->mJoinSem.inc();
ThreadDeletePolicy::deleteThread(threadHandle);
} else {
Expand Down

0 comments on commit 59cd522

Please sign in to comment.