diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-02-18 19:22:37 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-02-18 19:22:37 +0100 |
commit | cd44c0af71ace2eb8056c2b26b9249a5aa102b41 (patch) | |
tree | ed7a5c88611de6d3341086fbdc47f051c242271b /src | |
parent | 1b578255245e2e1347059ad7d9171cf822c723a8 (diff) |
Increase default stack size on Linux
Workaround for #4550.
Diffstat (limited to 'src')
-rw-r--r-- | src/nix/main.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nix/main.cc b/src/nix/main.cc index 5f4eb8918..1b68cf15b 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -17,6 +17,10 @@ #include <netdb.h> #include <netinet/in.h> +#if __linux__ +#include <sys/resource.h> +#endif + #include <nlohmann/json.hpp> extern std::string chrootHelperName; @@ -325,6 +329,17 @@ void mainWrapped(int argc, char * * argv) int main(int argc, char * * argv) { + // Increase the default stack size for the evaluator and for + // libstdc++'s std::regex. + #if __linux__ + rlim_t stackSize = 64 * 1024 * 1024; + struct rlimit limit; + if (getrlimit(RLIMIT_STACK, &limit) == 0 && limit.rlim_cur < stackSize) { + limit.rlim_cur = stackSize; + setrlimit(RLIMIT_STACK, &limit); + } + #endif + return nix::handleExceptions(argv[0], [&]() { nix::mainWrapped(argc, argv); }); |