2
0
Эх сурвалжийг харах

* don't access the thread instance after calling DoTerminate to avoid
race conditions in case DoTerminate can cause the thread to be freed
already. Side-effect: changing FreeOnTerminate in DoTerminate no longer
has any effects, but this is compatible with the generic code for
ThreadProc in objpas/classes/classes.inc (patch by Nikolai ZHUBR)

git-svn-id: trunk@14504 -

Jonas Maebe 15 жил өмнө
parent
commit
b214448b9e

+ 3 - 1
rtl/unix/tthread.inc

@@ -85,6 +85,7 @@ end;
 function ThreadFunc(parameter: Pointer): ptrint;
 function ThreadFunc(parameter: Pointer): ptrint;
 var
 var
   LThread: TThread;
   LThread: TThread;
+  LFreeOnTerminate: boolean;
 {$ifdef DEBUG_MT}
 {$ifdef DEBUG_MT}
   lErrorAddr, lErrorBase: Pointer;
   lErrorAddr, lErrorBase: Pointer;
 {$endif}
 {$endif}
@@ -143,8 +144,9 @@ begin
   Result := LThread.FReturnValue;
   Result := LThread.FReturnValue;
   WRITE_DEBUG('Result is ',Result);
   WRITE_DEBUG('Result is ',Result);
   LThread.FFinished := True;
   LThread.FFinished := True;
+  LFreeOnTerminate := LThread.FreeOnTerminate;
   LThread.DoTerminate;
   LThread.DoTerminate;
-  if LThread.FreeOnTerminate then
+  if LFreeOnTerminate then
     begin
     begin
       WRITE_DEBUG('Thread ',ptruint(lthread),' should be freed');
       WRITE_DEBUG('Thread ',ptruint(lthread),' should be freed');
       LThread.Free;
       LThread.Free;