@@ -34,24 +34,20 @@ static char *append_hex(uintptr_t d, char *buf, const char *end) {
3434 return buf;
3535}
3636
37- static void format_msg (const char *kind, uintptr_t caller,
38- const uintptr_t *address, char *buf, const char *end) {
37+ static void format_msg (const char *kind, uintptr_t caller, char *buf,
38+ const char *end) {
3939 buf = append_str (" ubsan: " , buf, end);
4040 buf = append_str (kind, buf, end);
4141 buf = append_str (" by 0x" , buf, end);
4242 buf = append_hex (caller, buf, end);
43- if (address) {
44- buf = append_str (" address 0x" , buf, end);
45- buf = append_hex (*address, buf, end);
46- }
4743 buf = append_str (" \n " , buf, end);
4844 if (buf == end)
4945 --buf; // Make sure we don't cause a buffer overflow.
5046 *buf = ' \0 ' ;
5147}
5248
5349SANITIZER_INTERFACE_WEAK_DEF (void , __ubsan_report_error, const char *kind,
54- uintptr_t caller, const uintptr_t *address ) {
50+ uintptr_t caller) {
5551 if (caller == 0 )
5652 return ;
5753 while (true ) {
@@ -84,32 +80,28 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error, const char *kind,
8480 __sanitizer::atomic_store_relaxed (&caller_pcs[sz], caller);
8581
8682 char msg_buf[128 ];
87- format_msg (kind, caller, address, msg_buf, msg_buf + sizeof (msg_buf));
83+ format_msg (kind, caller, msg_buf, msg_buf + sizeof (msg_buf));
8884 message (msg_buf);
8985 }
9086}
9187
9288SANITIZER_INTERFACE_WEAK_DEF (void , __ubsan_report_error_fatal, const char *kind,
93- uintptr_t caller, const uintptr_t *address ) {
89+ uintptr_t caller) {
9490 // Use another handlers, in case it's already overriden.
95- __ubsan_report_error (kind, caller, address );
91+ __ubsan_report_error (kind, caller);
9692}
9793
9894#if defined(__ANDROID__)
9995extern " C" __attribute__((weak)) void android_set_abort_message (const char *);
100- static void abort_with_message (const char *kind, uintptr_t caller,
101- const uintptr_t *address) {
96+ static void abort_with_message (const char *kind, uintptr_t caller) {
10297 char msg_buf[128 ];
103- format_msg (kind, caller, address, msg_buf, msg_buf + sizeof (msg_buf));
98+ format_msg (kind, caller, msg_buf, msg_buf + sizeof (msg_buf));
10499 if (&android_set_abort_message)
105100 android_set_abort_message (msg_buf);
106101 abort ();
107102}
108103#else
109- static void abort_with_message (const char *kind, uintptr_t caller,
110- const uintptr_t *address) {
111- abort ();
112- }
104+ static void abort_with_message (const char *kind, uintptr_t caller) { abort (); }
113105#endif
114106
115107#if SANITIZER_DEBUG
@@ -129,39 +121,21 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
129121
130122#define HANDLER_RECOVER (name, kind ) \
131123 INTERFACE void __ubsan_handle_##name##_minimal() { \
132- __ubsan_report_error (kind, GET_CALLER_PC (), nullptr ); \
124+ __ubsan_report_error (kind, GET_CALLER_PC ()); \
133125 }
134126
135127#define HANDLER_NORECOVER (name, kind ) \
136128 INTERFACE void __ubsan_handle_##name##_minimal_abort() { \
137129 uintptr_t caller = GET_CALLER_PC (); \
138- __ubsan_report_error_fatal (kind, caller, nullptr ); \
139- abort_with_message (kind, caller, nullptr ); \
130+ __ubsan_report_error_fatal (kind, caller); \
131+ abort_with_message (kind, caller); \
140132 }
141133
142134#define HANDLER (name, kind ) \
143135 HANDLER_RECOVER (name, kind) \
144136 HANDLER_NORECOVER(name, kind)
145137
146- #define HANDLER_RECOVER_PTR (name, kind ) \
147- INTERFACE void __ubsan_handle_##name##_minimal(const uintptr_t address) { \
148- __ubsan_report_error (kind, GET_CALLER_PC (), &address); \
149- }
150-
151- #define HANDLER_NORECOVER_PTR (name, kind ) \
152- INTERFACE void __ubsan_handle_##name##_minimal_abort( \
153- const uintptr_t address) { \
154- uintptr_t caller = GET_CALLER_PC (); \
155- __ubsan_report_error_fatal (kind, caller, &address); \
156- abort_with_message (kind, caller, &address); \
157- }
158-
159- // A version of a handler that takes a pointer to a value.
160- #define HANDLER_PTR (name, kind ) \
161- HANDLER_RECOVER_PTR (name, kind) \
162- HANDLER_NORECOVER_PTR(name, kind)
163-
164- HANDLER_PTR(type_mismatch, " type-mismatch" )
138+ HANDLER(type_mismatch, " type-mismatch" )
165139HANDLER(alignment_assumption, " alignment-assumption" )
166140HANDLER(add_overflow, " add-overflow" )
167141HANDLER(sub_overflow, " sub-overflow" )
0 commit comments