Skip to content

Commit d9f9064

Browse files
[ubsan_minimal] Add address argument to Android's abort message function (#152419)
#152192 forgot to make the argument changes to Android code in UBsan minimal causing a build error for Android LLVM: ``` /b/f/w/src/git/out/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:102:3: error: no matching function for call to 'format_msg' 102 | format_msg(kind, caller, msg_buf, msg_buf + sizeof(msg_buf)); | ^~~~~~~~~~ /b/f/w/src/git/out/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:37:13: note: candidate function not viable: requires 5 arguments, but 4 were provided 37 | static void format_msg(const char *kind, uintptr_t caller, | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 38 | const uintptr_t *address, char *buf, const char *end) { ``` This change adds the address argument to abort_with_message just like __ubsan_report_error_fatal so it can be passed to format_msg.
1 parent 44af26e commit d9f9064

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error_fatal, const char *kind,
9797

9898
#if defined(__ANDROID__)
9999
extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
100-
static void abort_with_message(const char *kind, uintptr_t caller) {
100+
static void abort_with_message(const char *kind, uintptr_t caller,
101+
const uintptr_t *address) {
101102
char msg_buf[128];
102-
format_msg(kind, caller, msg_buf, msg_buf + sizeof(msg_buf));
103+
format_msg(kind, caller, address, msg_buf, msg_buf + sizeof(msg_buf));
103104
if (&android_set_abort_message)
104105
android_set_abort_message(msg_buf);
105106
abort();
106107
}
107108
#else
108-
static void abort_with_message(const char *kind, uintptr_t caller) { abort(); }
109+
static void abort_with_message(const char *kind, uintptr_t caller,
110+
const uintptr_t *address) {
111+
abort();
112+
}
109113
#endif
110114

111115
#if SANITIZER_DEBUG
@@ -132,7 +136,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
132136
INTERFACE void __ubsan_handle_##name##_minimal_abort() { \
133137
uintptr_t caller = GET_CALLER_PC(); \
134138
__ubsan_report_error_fatal(kind, caller, nullptr); \
135-
abort_with_message(kind, caller); \
139+
abort_with_message(kind, caller, nullptr); \
136140
}
137141

138142
#define HANDLER(name, kind) \
@@ -149,7 +153,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
149153
const uintptr_t address) { \
150154
uintptr_t caller = GET_CALLER_PC(); \
151155
__ubsan_report_error_fatal(kind, caller, &address); \
152-
abort_with_message(kind, caller); \
156+
abort_with_message(kind, caller, &address); \
153157
}
154158

155159
// A version of a handler that takes a pointer to a value.

0 commit comments

Comments
 (0)