https://bugs.winehq.org/show_bug.cgi?id=54364
--- Comment #1 from Hans Leidekker hans@meelstraat.net --- (In reply to tjeerd.bakker38 from comment #0)
WinHttpSendRequest() fails with ERROR_OUTOFMEMORY when the WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET is set on systems with 256 cores. I've tracked it down to dlls/advapi32/crypt.c.
RtlGenRandom is implemented by calling NtQuerySystemInformation(SystemInterruptInformation, ...) with a buffer sufficient for the data from at most 128 CPUs. The buffer size is determined by the #define in line 2393:
#define MAX_CPUS 128
Changing this line to
#define MAX_CPUS 256
make the problem go away for me, but the problem will probably return when someone builds a system with even more cores. I would suggest implementing RtlGenRandom() with a better source of randomness instead.
Note that NtQuerySystemInformation(SystemInterruptInformation, ...) returns a buffer filled get with getrandom(). It's more a matter of finding the right interface to fetch the bytes from the Unix side than picking the right source. It would be nice if we could avoid introducing a PE/Unix split just for this purpose.
I think bumping the size to 256 is okay for now.