Surprising allocation in windows/compat.rs
is a footgun for custom allocators
#79118
Labels
A-allocators
Area: Custom and system allocators
O-windows
Operating system: Windows
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
This function is the problem:
rust/library/std/src/sys/windows/compat.rs
Lines 17 to 28 in f5230fb
AcquireSRWLockExclusive
is one of the functions utilizing this compatibility layer. However, most custom allocators indirectly rely on this function.This means that allocators must be re-entrant, which is essentially impossible since re-entrancy detection requires thread-local storage, which in turn calls
AcquireSRWLockExclusive
.For some reason I haven't been able to fathom, this does not always result in a crash, so many custom allocators which rely on TLS appear to work. However, seemingly inconsequential changes (such as changing the size of a struct) result in the program crashing with an access violation or stack overflow.
The fix is to remove this allocation and encode these strings at compile-time.
The text was updated successfully, but these errors were encountered: