Skip to content

Commit

Permalink
Remove broken stack size logic from Windows
Browse files Browse the repository at this point in the history
The API only changes the stack size once there's already a stack
overflow exception. Pretty useless.
  • Loading branch information
puffnfresh committed Jan 14, 2025
1 parent 2cb0ddf commit b644e57
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions src/libutil/current-process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
# include "namespaces.hh"
#endif

#ifndef _WIN32
# include <sys/resource.h>
#endif

namespace nix {

unsigned int getMaxCPU()
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit b644e57

Please sign in to comment.