Skip to content

Commit e0d1bab

Browse files
authored
POSIX: adjust the alt stack buffer
Glibc 2.34+ renames `SIGSTKSZ` to a `sysconf` query. Use that to dynamically query and allocate the buffer as a dynamically allocated static managed buffer.
1 parent a0d0ed6 commit e0d1bab

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Sources/Utils/POSIX/FaultHandler.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,23 @@ class FaultHandler {
3131
}
3232

3333
void installCatcher() {
34-
static char alt[SIGSTKSZ];
34+
#if defined(__APPLE__)
35+
long sz = SIGSTKSZ;
36+
static std::unique_ptr<char[]> alt = std::make_unique<char[]>(sz);
37+
#else
38+
long sz = sysconf(_SC_SIGSTKSZ);
39+
if (sz == -1)
40+
abort();
41+
42+
static std::unique_ptr<char[]> alt = std::make_unique<char[]>(sz);
43+
#endif
3544
struct sigaction sa;
3645
stack_t ss;
3746

3847
// Allocate our own signal stack so that fault handlers work even
3948
// when the stack pointer is busted.
40-
ss.ss_sp = alt;
41-
ss.ss_size = sizeof(alt);
49+
ss.ss_sp = alt.get();
50+
ss.ss_size = sz;
4251
ss.ss_flags = 0;
4352

4453
sa.sa_sigaction = FaultHandler::signalHandler;

0 commit comments

Comments
 (0)