These VirtualAlloc's may intermittently fail if the pagefile is growing...
Ah yeah, I see Firefox ran into that and added retries:
https://hacks.mozilla.org/2022/11/improving-firefox-stabilit...
Seems like a worthwhile change, though I'm not sure when I'll get around to it.
This is something you also need to do for other Win32 APIs, e.g. file write access may be temporarily blocked by anti-virus programs or whatever and not handling that makes unhappy users.
Never knew about the destructor feature for fiber local allocations!
At the time (11 years ago) I wanted this to run on Windows XP.
The APIs you use there (e.g. SleepConditionVariableSRW()) were only added in Vista.
I assume a big chunk of pthread emulation code at that time was implementing things like that.
[1] https://github.com/WebKit/WebKit/pull/41945 [2] https://github.com/WebKit/WebKit/blob/main/Source/bmalloc/li...