Compare commits

...

2 Commits

Author SHA1 Message Date
Pratik Mankawde
80465868fc Merge branch 'develop' into pratik/Add_NO_SANITIZE_ADDRESS_macro 2026-02-23 12:59:51 +00:00
Pratik Mankawde
6f5c54a4cc added the no-asan macro for Throw statements.
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-02-16 16:24:13 +00:00
4 changed files with 12 additions and 4 deletions

View File

@@ -111,6 +111,7 @@ words:
- gpgcheck - gpgcheck
- gpgkey - gpgkey
- hotwallet - hotwallet
- hwaddress
- hwrap - hwrap
- ifndef - ifndef
- inequation - inequation

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <xrpl/basics/sanitizers.h>
#include <xrpl/beast/type_name.h> #include <xrpl/beast/type_name.h>
#include <exception> #include <exception>
@@ -24,7 +25,7 @@ LogThrow(std::string const& title);
control to the next matching exception handler, if any. control to the next matching exception handler, if any.
Otherwise, std::terminate will be called. Otherwise, std::terminate will be called.
*/ */
[[noreturn]] inline void [[noreturn]] XRPL_NO_SANITIZE_ADDRESS inline void
Rethrow() Rethrow()
{ {
LogThrow("Re-throwing exception"); LogThrow("Re-throwing exception");
@@ -32,7 +33,7 @@ Rethrow()
} }
template <class E, class... Args> template <class E, class... Args>
[[noreturn]] inline void [[noreturn]] XRPL_NO_SANITIZE_ADDRESS inline void
Throw(Args&&... args) Throw(Args&&... args)
{ {
static_assert( static_assert(

View File

@@ -0,0 +1,6 @@
// Helper to disable ASan/HwASan for specific functions
#if defined(__GNUC__) || defined(__clang__)
#define XRPL_NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address", "hwaddress")))
#else
#define XRPL_NO_SANITIZE_ADDRESS
#endif

View File

@@ -258,7 +258,7 @@ Number::Guard::doRoundUp(
} }
bringIntoRange(negative, mantissa, exponent, minMantissa); bringIntoRange(negative, mantissa, exponent, minMantissa);
if (exponent > maxExponent) if (exponent > maxExponent)
throw std::overflow_error(location); Throw<std::overflow_error>(std::string(location));
} }
template <UnsignedMantissa T> template <UnsignedMantissa T>
@@ -298,7 +298,7 @@ Number::Guard::doRound(rep& drops, std::string location)
// or "(maxRep + 1) / 10", neither of which will round up when // or "(maxRep + 1) / 10", neither of which will round up when
// converting to rep, though the latter might overflow _before_ // converting to rep, though the latter might overflow _before_
// rounding. // rounding.
throw std::overflow_error(location); // LCOV_EXCL_LINE Throw<std::overflow_error>(std::string(location)); // LCOV_EXCL_LINE
} }
++drops; ++drops;
} }