-
Notifications
You must be signed in to change notification settings - Fork 136
Support printing backtrace when an assertion fails #330
Conversation
Codecov Report
@@ Coverage Diff @@
## master #330 +/- ##
==========================================
- Coverage 83.97% 83.96% -0.02%
==========================================
Files 50 50
Lines 9400 9400
Branches 2508 2508
==========================================
- Hits 7894 7893 -1
Misses 949 949
- Partials 557 558 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Cole Miller <[email protected]>
04eb809
to
a9c12a9
Compare
@@ -222,6 +222,11 @@ endif # LZ4_ENABLED | |||
|
|||
endif # UV_ENABLED | |||
|
|||
if BACKTRACE_ENABLED | |||
libraft_la_CFLAGS += -DRAFT_ASSERT_WITH_BACKTRACE | |||
libraft_la_LDFLAGS += -lbacktrace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compilation will fail if libbacktrace
is not found, probably a bit cleaner to detect it during the configure step itself, you can practically do the same as for libuv
in configure.ac
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, libbacktrace doesn't install a pkg-config entry (see ianlancetaylor/libbacktrace#65), so I'm not sure how to search for it from configure.ac. If they offered an amalgamation build I'd consider just dropping those files into our build system, but no such luck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, I can live with a failure further down the road, it's a debugging feature anyway. We could look for the header file, like in liblz4
's case, but I don't think it's worth the pain here.
More than once while looking at an assertion failure in Jepsen logs I've wished that it came with a backtrace -- this PR implements that.
Specifically, if RAFT_ASSERT_WITH_BACKTRACE is defined during compilation, we call into libbacktrace to print a symbolic backtrace before aborting. I still need to add the build system stuff to enable/disable this feature, find libbacktrace, and pass the appropriate flags during compilation.
Signed-off-by: Cole Miller [email protected]