11#include " sanitizer_common/sanitizer_atomic.h"
22
3- #include < stdlib.h>
43#include < stdint.h>
4+ #include < stdlib.h>
55#include < string.h>
66#include < unistd.h>
77
88#ifdef KERNEL_USE
99extern " C" void ubsan_message (const char *msg);
1010static void message (const char *msg) { ubsan_message (msg); }
1111#else
12- static void message (const char *msg) {
13- (void )write (2 , msg, strlen (msg));
14- }
12+ static void message (const char *msg) { (void )write (2 , msg, strlen (msg)); }
1513#endif
1614
1715static const int kMaxCallerPcs = 20 ;
@@ -62,16 +60,18 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error, const char *kind,
6260 uintptr_t p;
6361 for (unsigned i = 0 ; i < sz; ++i) {
6462 p = __sanitizer::atomic_load_relaxed (&caller_pcs[i]);
65- if (p == 0 ) break ; // Concurrent update.
63+ if (p == 0 )
64+ break ; // Concurrent update.
6665 if (p == caller)
6766 return ;
6867 }
69- if (p == 0 ) continue ; // FIXME: yield?
68+ if (p == 0 )
69+ continue ; // FIXME: yield?
7070 }
7171
7272 if (!__sanitizer::atomic_compare_exchange_strong (
7373 &caller_pcs_sz, &sz, sz + 1 , __sanitizer::memory_order_seq_cst))
74- continue ; // Concurrent update! Try again from the start.
74+ continue ; // Concurrent update! Try again from the start.
7575
7676 if (sz == kMaxCallerPcs ) {
7777 message (" ubsan: too many errors\n " );
@@ -85,6 +85,12 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error, const char *kind,
8585 }
8686}
8787
88+ SANITIZER_INTERFACE_WEAK_DEF (void , __ubsan_report_error_fatal, const char *kind,
89+ uintptr_t caller) {
90+ // Use another handlers, in case it's already overriden.
91+ __ubsan_report_error (kind, caller);
92+ }
93+
8894#if defined(__ANDROID__)
8995extern " C" __attribute__((weak)) void android_set_abort_message (const char *);
9096static void abort_with_message (const char *kind, uintptr_t caller) {
@@ -121,7 +127,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
121127#define HANDLER_NORECOVER (name, kind ) \
122128 INTERFACE void __ubsan_handle_##name##_minimal_abort() { \
123129 uintptr_t caller = GET_CALLER_PC (); \
124- __ubsan_report_error (kind, caller); \
130+ __ubsan_report_error_fatal (kind, caller); \
125131 abort_with_message (kind, caller); \
126132 }
127133
0 commit comments