Hello people, (Sorry if this appears twice on the list, I've made one attempt to post before I subscribed to the list, and it seems it was silently rejected)
Could someone please consider the patch below. This patch makes ThreadFunc (rtl/unix/tthread.inc) behave like the generic ThreadProc (classes.inc). That is, thread object will never be accessed by RTL after DoTerminate call (unless FreeOnTerminate=true, of course). As a side effect, any changes to FreeOnTerminate within DoTerminate are ignored. (The reason this is important is because one may want to initiate thread object disposal from within DoTerminate, but use another thread to get some data from the no-longer-running thread and then actually dispose it) This patch is against version 2.4.0rc1. Thank you! Nikolai ZHUBR --- fpcsrc/rtl/unix/tthread.inc.orig Thu Jan 24 22:30:56 2008 +++ fpcsrc/rtl/unix/tthread.inc Sun Dec 27 14:12:20 2009 @@ -85,6 +85,7 @@ function ThreadFunc(parameter: Pointer): ptrint; var LThread: TThread; + LFreeOnTerminate: boolean; {$ifdef DEBUG_MT} lErrorAddr, lErrorBase: Pointer; {$endif} @@ -143,8 +144,9 @@ Result := LThread.FReturnValue; WRITE_DEBUG('Result is ',Result); LThread.FFinished := True; + LFreeOnTerminate := LThread.FreeOnTerminate; LThread.DoTerminate; - if LThread.FreeOnTerminate then + if LFreeOnTerminate then begin WRITE_DEBUG('Thread ',ptruint(lthread),' should be freed'); LThread.Free; _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel