Problem
When a benchmark triggers an assertion failure or abort deeper down the stack, the output provides no indication of which benchmark failed.
Reproducer
To reproduce, inject a failure outside the benchmarks:
0diff --git a/src/streams.h b/src/streams.h
1--- a/src/streams.h (revision aa2eebdb1e8182394d44fd9719e316ea52926cab)
2+++ b/src/streams.h (date 1767091264182)
3@@ -179,6 +179,7 @@
4
5 bool Rewind(std::optional<size_type> n = std::nullopt)
6 {
7+ Assert(false);
8 // Total rewind if no size is passed
9 if (!n) {
10 m_read_pos = 0;
and run with a filter matching multiple benchmarks:
0rm -rfd build && cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_BENCH=ON && cmake --build build -j$(nproc) && ./build/bin/bench_bitcoin -filter='DeserializeAndCheckBlockTest|DeserializeBlockTest|PrevectorDeserialize' -sanity-check
Before - the outputs provide no indication which benchmark failed:
0streams.h:182 bool DataStream::Rewind(std::optional<size_type>): Assertion `false' failed.
1zsh: abort ./build/bin/bench_bitcoin -sanity-check
Fix
This PR adds a SIGABRT signal handler that prints the currently running benchmark’s name before re-raising the signal. The name only appears on failure, not before each benchmark starts, keeping normal output clean.
After - the benchmark name is logged, and the signal re-raised:
0streams.h:182 bool DataStream::Rewind(std::optional<size_type>): Assertion `false' failed.
1Benchmark failed: DeserializeAndCheckBlockTest.
2zsh: abort ./build/bin/bench_bitcoin -sanity-check
Considerations
Works in both debug and release builds since it doesn’t rely on stack traces (which would require debug symbols).