Skip to content

Commit 2349c3d

Browse files
committed
setStackSize: Warn when the desired stack size can't be set
1 parent f6aeca0 commit 2349c3d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libutil/current-process.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ void setStackSize(size_t stackSize)
6565
struct rlimit limit;
6666
if (getrlimit(RLIMIT_STACK, &limit) == 0 && static_cast<size_t>(limit.rlim_cur) < stackSize) {
6767
savedStackSize = limit.rlim_cur;
68+
if (limit.rlim_max < static_cast<rlim_t>(stackSize)) {
69+
logger->log(
70+
lvlWarn,
71+
HintFmt(
72+
"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%'.",
73+
limit.rlim_max,
74+
stackSize,
75+
stackSize / 1024)
76+
.str());
77+
}
6878
auto requestedSize = std::min(static_cast<rlim_t>(stackSize), limit.rlim_max);
6979
limit.rlim_cur = requestedSize;
7080
if (setrlimit(RLIMIT_STACK, &limit) != 0) {

0 commit comments

Comments
 (0)