From ddee85735f38dc77f233dc16840658c8764e65cb Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Wed, 15 Sep 2021 15:23:42 -0400 Subject: SERVER-59459 With glibc-2.34, MINSIGSTKSZ is no longer a constant (cherry picked from commit ef08d0dbc99db8c4620512e92bfb3154282eb5d3) (cherry picked from commit 959d10ecad8f59dbbb755b2eebab2bffed6bab32) (cherry picked from commit 167a957f8d4d71db7a3a720052ec72e5d68724f7) --- src/mongo/stdx/thread.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mongo/stdx/thread.h b/src/mongo/stdx/thread.h index f8058279e34..a4142323752 100644 --- a/src/mongo/stdx/thread.h +++ b/src/mongo/stdx/thread.h @@ -75,11 +75,19 @@ public: } private: + static size_t _getStackSize() { + // It would be nice for this to be a constexpr, but + // MINSIGSTKSZ became a macro that invoked `sysconf` in glibc + // 2.34. + static const std::size_t kMinSigStkSz = MINSIGSTKSZ; + return std::max(kMongoMinSignalStackSize, kMinSigStkSz); + } + void _install() const { stack_t ss = {}; ss.ss_sp = _stackStorage.get(); ss.ss_flags = 0; - ss.ss_size = kStackSize; + ss.ss_size = _getStackSize(); if (sigaltstack(&ss, nullptr)) { abort(); } @@ -106,9 +114,7 @@ private: // ( https://jira.mongodb.org/secure/attachment/233569/233569_stacktrace-writeup.txt ) static constexpr std::size_t kMongoMinSignalStackSize = std::size_t{64} << 10; - static constexpr std::size_t kStackSize = - std::max(kMongoMinSignalStackSize, std::size_t{MINSIGSTKSZ}); - std::unique_ptr _stackStorage = std::make_unique(kStackSize); + std::unique_ptr _stackStorage = std::make_unique(_getStackSize()); #else // !MONGO_HAS_SIGALTSTACK auto makeInstallGuard() const { -- cgit v1.2.1