You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Imagine the thread checks Terminated and a context switch happens right after that. The main thread then calls TUniqueInstance.Destroy and FSocket is freed. When the thread continues to execute it calls FSocket.Accept(Client), but FSocket has already been freed.)
The text was updated successfully, but these errors were encountered:
Reading through the code, I found what looks like a race condition which can cause a "use-after-free".
When TUniqueInstance is destroyed, FThread is asked to terminate and FSocket is freed:
https://github.com/sysrpl/Codebot.Cross/blob/master/source/codebot/codebot.unique.pas#L77-L79
But the FThread can still be running and attempt to access FSocket after it is freed.
https://github.com/sysrpl/Codebot.Cross/blob/master/source/codebot/codebot.unique.pas#L99
(Imagine the thread checks Terminated and a context switch happens right after that. The main thread then calls TUniqueInstance.Destroy and FSocket is freed. When the thread continues to execute it calls FSocket.Accept(Client), but FSocket has already been freed.)
The text was updated successfully, but these errors were encountered: