[Lazarus] Mutlithreaded Dll Callback crashes my Application
Sven Barth
pascaldragon at googlemail.com
Wed Aug 25 22:05:32 CEST 2010
On 25.08.2010 21:33, José Mejuto wrote:
> Hello Lazarus-List,
>
> Wednesday, August 25, 2010, 8:47:23 PM, you wrote:
>
> SB> IsMultiThread is only a variable. Setting it is only useful recognized
> SB> once FPC threading code is called. So instead of setting IsMultiThread
> SB> to true you must create at least one thread in FPC (it can be a dummy
> SB> thread that immediately terminates).
>
> In Delphi setting IsMultithread to true is a must to use non TThread
> threads. Taken from Embarcadero QA:
>
FPC is not Delphi and in this regard those two differ. The method
SysInitMultiThreading in rtl/win/systhrd.pas which initializes the
thread local storage is only called on two locations:
- when a new thread is created using FPC routines (BeginThread, TThread)
- when the unit system is initalized (using InitSystemThreads) AND if
the application is a library
If you don't create a thread the thread local storage won't be
initialized and thus threadvars won't work and thus the heap will not
work correctly.
> Also the one thread creation is only for Unix systems, win32 does not
> have this problem since a lot of time.
Windows DOES have this problem.
>
> On the other hand, if Unix needs one thread creation then it should be
> automagically done in the initialization section of cthreads, do not ?
>
This might indeed be a solution.
Regards,
Sven
More information about the Lazarus
mailing list