ci: Silence UBSan diagnostics in the ubsan build config

The debian-trixie-clang-22-amd64-debug-ubsan job logs many non-fatal
UBSan `runtime error:` lines (it passes because halt_on_error=false).
These come from two places that needed different fixes.

Build-time: the protocol code-gen and build steps run instrumented
dependency tools (protoc, grpc) before the "Set sanitizer options" step
exported UBSAN_OPTIONS, so the suppression list never applied to them.
Move that step to run right after "Configure CMake" — before code-gen
and build — reusing the existing ${GITHUB_WORKSPACE}/$GITHUB_ENV
mechanism so the path resolves correctly inside the container job.

Test-time: extend ubsan.supp. unsigned-integer-overflow and
float-divide-by-zero are separate checks, not part of the `undefined`
group, so undefined:<x> keys do not cover them. Add broad
unsigned-integer-overflow keys for absl and protobuf (matching the
existing boost handling), a few libstdc++ headers, and narrowly
function-scoped entries for rippled's intentional wraparound (hashing,
PRNG, counters guarded by explicit overflow checks) plus test
arithmetic, each with a rationale comment.

Fix the one genuine issue in code: a diagnostic JLOG line in
doLedgerGrpc divided the extract time by the object / transaction
counts, which are zero for an empty ledger. Guard the per-item rates.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-06-11 16:42:14 +01:00
parent 09c36d066e
commit ecfb570ea4
3 changed files with 107 additions and 26 deletions

View File

@@ -349,13 +349,15 @@ doLedgerGrpc(RPC::GRPCContext<org::xrpl::rpc::v1::GetLedgerRequest>& context)
auto end = std::chrono::system_clock::now();
auto duration =
std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() * 1.0;
// Guard the per-item rates: an empty ledger has zero objects and/or zero
// transactions, and dividing by zero is undefined for these doubles.
auto const numObjects = response.ledger_objects().objects_size();
auto const numTxns = response.transactions_list().transactions_size();
std::string const msPerObj = numObjects > 0 ? std::to_string(duration / numObjects) : "n/a";
std::string const msPerTxn = numTxns > 0 ? std::to_string(duration / numTxns) : "n/a";
JLOG(context.j.warn()) << __func__ << " - Extract time = " << duration
<< " - num objects = " << response.ledger_objects().objects_size()
<< " - num txns = " << response.transactions_list().transactions_size()
<< " - ms per obj "
<< duration / response.ledger_objects().objects_size()
<< " - ms per txn "
<< duration / response.transactions_list().transactions_size();
<< " - num objects = " << numObjects << " - num txns = " << numTxns
<< " - ms per obj " << msPerObj << " - ms per txn " << msPerTxn;
return {response, status};
}