Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Support printing backtrace when an assertion fails #330

Merged
merged 1 commit into from
Dec 5, 2022

Conversation

cole-miller
Copy link
Contributor

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 cole.miller@canonical.com

@codecov
Copy link

codecov bot commented Nov 29, 2022

Codecov Report

Merging #330 (a9c12a9) into master (5637dcf) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            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     
Impacted Files Coverage Δ
src/fixture.c 93.82% <0.00%> (-0.10%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/assert.h Outdated Show resolved Hide resolved
Signed-off-by: Cole Miller <cole.miller@canonical.com>
@@ -222,6 +222,11 @@ endif # LZ4_ENABLED

endif # UV_ENABLED

if BACKTRACE_ENABLED
libraft_la_CFLAGS += -DRAFT_ASSERT_WITH_BACKTRACE
libraft_la_LDFLAGS += -lbacktrace
Copy link
Contributor

@MathieuBordere MathieuBordere Nov 30, 2022

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.

Copy link
Contributor Author

@cole-miller cole-miller Nov 30, 2022

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.

Copy link
Contributor

@MathieuBordere MathieuBordere Nov 30, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants