[fpc-pascal] changes in TThread.OnTerminate in fcp-3.0?

Sven Barth pascaldragon at googlemail.com
Thu Dec 10 11:13:27 CET 2015


Am 10.12.2015 11:05 schrieb "Luca Olivetti" <luca at ventoso.org>:
>
> Hello,
>
> in a couple of programs I'm using this idiom:
>
>
> FMyThread:=TMyTread.Create;
> FMyThread.FreeOnTerminate:=false;
> FMyThread.OnTerminate:=@MyThreadTerminate
>
> procedure TMyForm.MyThreadTerminate(Sender:TObject);
> begin
>   //do something with FMyThread then
>   FreeAndNil(FMyThread);
> end;
>
>
> With fpc 2.6.4 it worked flawlessly, with fpc 3.0 sometimes it causes a
sigsev somewhere inside CheckSynchronize.
>
> I could find nothing here
> http://wiki.freepascal.org/User_Changes_3.0
> related to this.
> I realize that's an implementation detail so probably what I did was
wrong (was it?).

I'd need to check what the RTL does after OnTerminate is called, but it
could be that this worked by chance...

> What are the possible solutions (apart from omitting the call to
FreeAndNil and setting FreeOnTerminate to true)?

That would be the safest solution (you can set FMyThread to Nil however
inside that handler).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20151210/22fad601/attachment.html>


More information about the fpc-pascal mailing list