From 2349c3dbde77ea7ef32a89eea2c09048d93c671e Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 15 Oct 2025 22:40:31 +0200 Subject: [PATCH] setStackSize: Warn when the desired stack size can't be set --- src/libutil/current-process.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libutil/current-process.cc b/src/libutil/current-process.cc index 988621014..10522d5ae 100644 --- a/src/libutil/current-process.cc +++ b/src/libutil/current-process.cc @@ -65,6 +65,16 @@ void setStackSize(size_t stackSize) struct rlimit limit; if (getrlimit(RLIMIT_STACK, &limit) == 0 && static_cast(limit.rlim_cur) < stackSize) { savedStackSize = limit.rlim_cur; + if (limit.rlim_max < static_cast(stackSize)) { + logger->log( + lvlWarn, + HintFmt( + "Stack size hard limit is %1%, which is less than the desired %2%. If possible, increase the hard limit, e.g. with 'ulimit -Hs %3%'.", + limit.rlim_max, + stackSize, + stackSize / 1024) + .str()); + } auto requestedSize = std::min(static_cast(stackSize), limit.rlim_max); limit.rlim_cur = requestedSize; if (setrlimit(RLIMIT_STACK, &limit) != 0) {