[asio-users] What's the reason ASIO's tss_ptr doesn't use __declspec(thread) on Windows?
Brought to you by:
chris_kohlhoff
From: Groke, P. <pau...@dy...> - 2021-02-02 15:08:17
|
Hi, I already asked this on the Boost developer mailing list - but I guess that was the wrong place to ask. So I'm cross-posting it here. Sorry for that. (We're using Boost.Asio but the code in question is the same in both, so I guess it doesn't matter.) I've noticed that ASIO's tss_ptr implementation doesn't use __declspec(thread) on Windows, except when compiling for WinRT. Instead it uses the win_tss_ptr implementation - which will cause a crash when there's no free TLS index. (There are static tss_ptr instances and loading a DLL where a ctor of a static variables throws a C++ exception seems to cause a crash -- no surprise there). AFAIK using implicit TLS via __declspec(thread) should fix this so that loading a DLL either works or fails gracefully. One problem that I know of with implicit TLS is that it fails catastrophically on Windows versions before Vista. Since WinRT wasn't available on pre-Vista versions, this might be a reason to restrict it to WinRT. But I don't know if there are/were other reasons to restrict use of implicit TLS to WinRT. So... is there another reason? If there's no other reason, that would be great, because we don't have to support pre-Vista versions. Meaning we could simply patch ASIO to use implicit TLS for MSVC in general. Regards, Paul Groke The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. Dynatrace Austria GmbH (registration number FN 91482h) is a company registered in Linz whose registered office is at 4020 Linz, Austria, Am Fünfundzwanziger Turm 20 |