Significantly refactor fatal error handling

Because new glibc has changed `MINSIGSTKSZ` to be a syscall instead
of being constant, the signal posix handling needed changes, as it
used the value in constexpr context, for deciding size of an array.
It would be simple to fix it by having the handler determine the
signal handling stack size and allocate the memory every time the
handler is being installed, but that would add another allocation
and a syscall every time a test case is entered.

Instead, I split apart the idea of preparing fatal error handlers,
and engaging them, so that the memory can be allocated only once
and still be guarded by RAII.

Also turns out that Catch2's use of `MINSIGSTKSZ` was wrong, and
we should've been using `SIGSTKSZ` the whole time, which we use now.

Closes #2178
This commit is contained in:
Martin Hořeňovský
2021-05-09 23:34:15 +02:00
parent cbcab2dbcd
commit c0d0a50bdb
4 changed files with 193 additions and 104 deletions
+2 -2
View File
@@ -459,10 +459,10 @@ namespace Catch {
}
void RunContext::invokeActiveTestCase() {
// We need to register a handler for signals/structured exceptions
// We need to engage a handler for signals/structured exceptions
// before running the tests themselves, or the binary can crash
// without failed test being reported.
FatalConditionHandler _;
FatalConditionHandlerGuard _(&m_fatalConditionhandler);
m_activeTestCase->invoke();
}