[Lazarus] Mutlithreaded Dll Callback crashes my Application

Sven Barth pascaldragon at googlemail.com
Fri Aug 27 13:55:19 CEST 2010


Am 27.08.2010 12:27, schrieb Maik Wojcieszak:
> Hi,
>
> What exactly does this
>
> System.IsMultiThread := true;
>
> do ?
>
> If I use external threads with my thread creation callback it works fine
> with
> System.IsMultiThread := false;
> If I set it to true the app crashes when creating the first threads.
> If I use the suggested initialisation with the dummy thread it works
> too, but with
> System.IsMultiThread := true;
>
> Thanks in advance,
> Maik
>

I did a quick search in the source of the RTL. IsMultiThread is mostly 
tested to check whether multi threading was already initialised. 
Especially on POSIX systems you MUST NOT set IsMultiThread to True or 
the threadvar system won't be initialized (win32 does a more 
"intelligent" test).

The interesting thing is though that IsMultiThread is never set to True 
by the RTL in POSIX systems...

The creation of a dummy thread should be enough. You can set 
IsMultiThread to true after the thread has run though (to circumvent the 
POSIX problem I mentioned above).

Regards,
Sven




More information about the Lazarus mailing list