You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use libunwind instead of libbacktrace to build stack traces. This fixes a segfault issue with platforms using libexecinfo and is generally more portable.
Copy file name to clipboardExpand all lines: ChangeLog.txt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ Fixed bugs:
7
7
8
8
Compatibility:
9
9
* Fixed some incompatibilities with systems using the musl libc
10
+
* Use libunwind instead of libbacktrace to build stack traces. This fixes a segfault issue with platforms using libexecinfo and is generally more portable.
Copy file name to clipboardExpand all lines: src/cpp-utils/process/SignalCatcher.cpp
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,8 @@ class SignalCatcherImpl final {
88
88
, _registerer(signal, this)
89
89
, _handler(signal) {
90
90
// note: the order of the members ensures that:
91
-
// - when registering the signal handler fails, the registerer will be destroyed, unregistering the signal_occurred_flag,
91
+
// - when registering the signal handler, the SignalCatcher impl already has a valid _signal_occurred_flag set.
92
+
// - when registering the signal handler fails, the _registerer will be destroyed again, unregistering this SignalCatcherImpl,
92
93
// i.e. there is no leak.
93
94
94
95
// Allow only the set of signals that is supported on all platforms, see for Windows: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/signal?view=vs-2017
// Check that we're not running into http://savannah.nongnu.org/bugs/?43752
30
+
voidcheck_against_libunwind_bug() {
31
+
if (already_checked_for_libunwind_bug.exchange(true)) {
32
+
return;
33
+
}
34
+
35
+
// set new signal handler
36
+
sigset_t old_value = _sigemptyset();
37
+
sigset_t new_value = _sigemptyset();
38
+
39
+
_sigmask(&new_value, &old_value);
40
+
41
+
sigset_t before_exception = _sigemptyset();
42
+
_sigmask(nullptr, &before_exception);
43
+
44
+
// throw an exception
45
+
try {
46
+
throwstd::runtime_error("Some exception");
47
+
} catch (const std::exception &e) {}
48
+
49
+
sigset_t after_exception = _sigemptyset();
50
+
_sigmask(nullptr, &after_exception);
51
+
52
+
// reset to old signal handler
53
+
_sigmask(&old_value, nullptr);
54
+
55
+
// check that the exception didn't screw up the signal mask
56
+
if (0 != std::memcmp(&before_exception, &after_exception, sizeof(sigset_t))) { // NOLINT(cppcoreguidelines-pro-type-union-access)
57
+
ASSERT(false,
58
+
"Throwing an exception screwed up the signal mask. You likely ran into this bug: http://savannah.nongnu.org/bugs/?43752 . Please build CryFS against a newer version of libunwind or build libunwind with --disable-cxx-exceptions.");
0 commit comments