Skip to content

Commit

Permalink
Handle dynamic stack size on GLIBC > 2.33
Browse files Browse the repository at this point in the history
On GLIBC 2.33, `MINSIGSTKSZ` is not a constant. This can be detected
at compile time by the presence of either `_SC_SIGSTKSZ_SOURCE` or
`_GNU_SOURCE`.

If either are define, hardcode the size we want rather than compare it,
since we can't do that in a constant expression anymore.

Signed-off-by: Michel Alexandre Salim <michel@michel-slm.name>
  • Loading branch information
michel-slm committed Nov 4, 2021
1 parent 912df7d commit f83d032
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion extras/catch_amalgamated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3750,8 +3750,14 @@ namespace Catch {
};

// 32kb for the alternate stack seems to be sufficient. However, this value
// is experimentally determined, so that's not guaranteed.
// is experimentally determines, so that's not guaranteed.
#if defined(_SC_SIGSTKSZ_SOURCE) || defined(_GNU_SOURCE)
// on glibc > 2.33 this is no longer constant, see
// https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=85e84fe53699fe9e392edffa993612ce08b2954a;hb=HEAD
static constexpr std::size_t sigStackSize = 32768;
#else
static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
#endif

static SignalDefs signalDefs[] = {
{ SIGINT, "SIGINT - Terminal interrupt signal" },
Expand Down

0 comments on commit f83d032

Please sign in to comment.