[Lazarus] TThread.CurrentThread fails on Linux

Mario R. Carro mcarro at gmx.net
Mon Sep 16 23:13:14 CEST 2013


Hello all.

In it's current form (r23227) CurrentThreadVar it's not initialized 
before calling Execute in the TThread implementation for Linux (Unix).

Due to this the calls to TThread.CurrentThread always returns references 
to TExternalThread instances, guessing that the current thread is not a 
FPC thread (due to CurrentThreadVar being nil), even for actual TThread 
threads.

Adding the line:

	CurrentThreadVar := LThread;

somewhere before calling Execute in ThreadFunc in rtl/unix/tthread.inc
solves this problem.

Also: the TExternalThread instances created by TThread.CurrentThread are 
never freed, and so effectively leaked, isn't it?

Thanks,
Mario




More information about the Lazarus mailing list