1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 13:41:15 +02:00

Remove broken stack size logic from Windows

The API only changes the stack size once there's already a stack
overflow exception. Pretty useless.
This commit is contained in:
Brian McKenna 2024-11-15 10:45:29 +11:00
parent 2cb0ddfe4e
commit b644e5750e

View file

@ -19,10 +19,6 @@
# include "namespaces.hh" # include "namespaces.hh"
#endif #endif
#ifndef _WIN32
# include <sys/resource.h>
#endif
namespace nix { namespace nix {
unsigned int getMaxCPU() unsigned int getMaxCPU()
@ -77,29 +73,6 @@ void setStackSize(size_t stackSize)
); );
} }
} }
#else
ULONG_PTR stackLow, stackHigh;
GetCurrentThreadStackLimits(&stackLow, &stackHigh);
ULONG maxStackSize = stackHigh - stackLow;
ULONG currStackSize = 0;
// This retrieves the current promised stack size
SetThreadStackGuarantee(&currStackSize);
if (currStackSize < stackSize) {
savedStackSize = currStackSize;
ULONG newStackSize = std::min(static_cast<ULONG>(stackSize), maxStackSize);
if (SetThreadStackGuarantee(&newStackSize) == 0) {
logger->log(
lvlError,
HintFmt(
"Failed to increase stack size from %1% to %2% (maximum allowed stack size: %3%): %4%",
savedStackSize,
stackSize,
maxStackSize,
std::to_string(GetLastError())
).str()
);
}
}
#endif #endif
} }