On 20/12/2022 15:08, Martin wrote:
Ok, I don't know too much about the whole initialization....
But on the off chance of triggering some ideas, I throw in a couple of my thoughts....

On 19/12/2022 07:42, Sven Barth wrote:

This is likely to be the cause, cause the EXEC_TLS_CALLBACK is executed by Windows for every thread that is started for an application. And if the debugger triggers the start of a thread...

Maybe, maybe not always? But, yes at least in the case that I documented in 2018: https://lists.freepascal.org/pipermail/fpc-devel/2018-July/039374.html

While I just looked through that code, I came to think there may be yet another issue.

If a thread is started, that can call EXEC_TLS_CALLBACK.
And EXEC_TLS_CALLBACK  can call InitHeap (in DLL_PROCESS_ATTACH) before the main thread has run InitHeap.

But InitHeap does not seem to be threadsafe.

InitHeap itself does probably work if it runs overlapping. But, if one thread already goes into using the heap (e.g. allocating) while the other still is in InitHeap... That likely does not go well.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to