Skip to content

Commit ef08d0d

Browse files
acmorrowEvergreen Agent
authored andcommitted
SERVER-59459 With glibc-2.34, MINSIGSTKSZ is no longer a constant
1 parent 4635c1f commit ef08d0d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/mongo/stdx/thread.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,19 @@ class SigAltStackController {
7676
}
7777

7878
private:
79+
static size_t _getStackSize() {
80+
// It would be nice for this to be a constexpr, but
81+
// MINSIGSTKSZ became a macro that invoked `sysconf` in glibc
82+
// 2.34.
83+
static const std::size_t kMinSigStkSz = MINSIGSTKSZ;
84+
return std::max(kMongoMinSignalStackSize, kMinSigStkSz);
85+
}
86+
7987
void _install() const {
8088
stack_t ss = {};
8189
ss.ss_sp = _stackStorage.get();
8290
ss.ss_flags = 0;
83-
ss.ss_size = kStackSize;
91+
ss.ss_size = _getStackSize();
8492
if (sigaltstack(&ss, nullptr)) {
8593
abort();
8694
}
@@ -107,9 +115,7 @@ class SigAltStackController {
107115
// ( https://jira.mongodb.org/secure/attachment/233569/233569_stacktrace-writeup.txt )
108116
static constexpr std::size_t kMongoMinSignalStackSize = std::size_t{64} << 10;
109117

110-
static constexpr std::size_t kStackSize =
111-
std::max(kMongoMinSignalStackSize, std::size_t{MINSIGSTKSZ});
112-
std::unique_ptr<std::byte[]> _stackStorage = std::make_unique<std::byte[]>(kStackSize);
118+
std::unique_ptr<std::byte[]> _stackStorage = std::make_unique<std::byte[]>(_getStackSize());
113119

114120
#else // !MONGO_HAS_SIGALTSTACK
115121
auto makeInstallGuard() const {

0 commit comments

Comments
 (0)