-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Reconsider magic static usage, as there should be no portability issues since XP dropping #673
Comments
Windows itself had concerns about using magic statics (solved by our avoidance of them). I'm not an expert in this area, but the issue involved DLLs calling DisableThreadLibraryCalls. If the DLL uses TLS (e.g. due to magic statics), this call has no effect, leading to DllMain being called on thread start/end, which increases costs. (Microsoft-internal wiki page.) I believe that we should continue avoiding magic statics, but I've marked this as |
@StephanTLavavej , thanks, this sound like strong enough reason. I wouldn't object if you close this issue right away. |
Thanks for filing the issue! There are definitely things we avoided in the past that are safe to use now, so it's always good to take another look. |
Yeah, this particular problem possibly could be be fixed in future, especially if concentrate on just magic static, and don't fix it for TLS directory is this (I'm showing 64-bit versions, but 32-bit only differs in types):
With only magic statics in module the array is empty, it starts with nullptr-terminator. But I believe that such behavior of But actually magic static does not rely on DLL callbacks, since it works for exe the same as for DLL. So if a function is added, say, (Sure above is a speculation, based on the information known to me so far) |
I guess the fixed function |
Sounds like a bug/suggestion for the Windows API which could be reported via the Feedback Hub app. (We can't do anything about this in the STL.) |
I'm referring to this #448 (comment)
I think that TLS algorithm starting from Vista allows virtually infinite TLS slots (that is limited only by virtual address space).
I think the algorithm abandons old TLS tables without deallocating them. They are deallocated on thread exit. TLS slot table just grows, but with ability of slot reuse. Something like this.
I'm not sure if it is true for Vista, but at least for Windows 10 it seems to work.
I can show, please follow me:
The text was updated successfully, but these errors were encountered: