[Development] thread_local: replacing GCC with Clang for MinGW
Olivier Goffart
olivier at woboq.com
Sun Aug 25 09:44:51 CEST 2019
On 24.08.19 18:04, Thiago Macieira wrote:
> [...] That means we must continue to use
> QThreadStorage where we need non-POD thread-local storage, which only works[*]
> in QThread-started threads.
>
> [*] it won't crash if you use QThreadStorage with a thread started with
> something else, despite what the source code says, but it will leak memory.
The leak will only happen on Windows.
One could fix the leak by re-implementing DllMain in QtCore and using the
DLL_THREAD_DETACH hook to delete the QAdoptedThread
https://docs.microsoft.com/en-us/windows/win32/dlls/dllmain
That would fix the leak for dynamic Qt build.
But for static build we would need another trick.
The comments from this file are pretty interesting and would provide a solution:
https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/thread_local.rs#L130
--
Olivier
Woboq - Qt services and support - https://woboq.com - https://code.woboq.org
More information about the Development
mailing list