-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Windows] Fix thread local storage cleanup #2902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CC @compnerd |
Thanks for finding and fixing this. Yes, the CoreFoundation implementation switched to |
@swift-ci please test |
@compnerd BTW do we still need I could make sure it is actual behavior and remove |
Hmm, if the DLL_THREAD_DETACH is only doing this to handle the cleanup on the unload, we should remove it as the FLS will be sufficient for the cleanup. |
I will run extended tests to make sure everything is ok without DLL_THREAD_DETACH cleanup. Converting this to draft for now. |
Foundation uses Fls now. Fls provides automatic cleanup, and manual finalization on DLL_THREAD_DETACH is not needed.
Seems like everything is ok and we could just remove old finalization instead of fixing it. Did not run into any new issues for last days. |
@swift-ci please test |
CC: @millenomi any objections to the change to CF here? |
Is this bugfix worth backporting to 5.3? |
CoreFoundation thread local storage on Windows is based on FLS API. FLS provides automatic cleanup of storage, and it is already got used. Old manual cleanup is not needed anymore.
We have observed often crashes in thread cleanup routines of CRT. Despite I didn't manage to extract the issue out of live project code, I suppose that mixing TLS and FLS in cleanup code could eventually corrupt the storage. Replacing
TlsGetValue
withFlsGetValue
brings desired stability, but, as the code is obsolete, we could just remove it.