[compiler-rt] [ubsan_minimal] Add address argument to Android's abort message function (PR #152419)
Sharjeel Khan via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 17:59:23 PDT 2025
https://github.com/Sharjeel-Khan updated https://github.com/llvm/llvm-project/pull/152419
>From eea59e2a1da28cfadc2d54fd7997cb878b26b8ae Mon Sep 17 00:00:00 2001
From: Sharjeel Khan <sharjeelkhan at google.com>
Date: Thu, 7 Aug 2025 00:32:12 +0000
Subject: [PATCH 1/3] [ubsan_minimal] Add address argument to Android's abort
message function
https://github.com/llvm/llvm-project/pull/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.
---
.../lib/ubsan_minimal/ubsan_minimal_handlers.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index b1f4eab26de0e..2295162021f85 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -97,15 +97,15 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error_fatal, const char *kind,
#if defined(__ANDROID__)
extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
-static void abort_with_message(const char *kind, uintptr_t caller) {
+static void abort_with_message(const char *kind, uintptr_t caller, const uintptr_t *address) {
char msg_buf[128];
- format_msg(kind, caller, msg_buf, msg_buf + sizeof(msg_buf));
+ format_msg(kind, caller, address, msg_buf, msg_buf + sizeof(msg_buf));
if (&android_set_abort_message)
android_set_abort_message(msg_buf);
abort();
}
#else
-static void abort_with_message(const char *kind, uintptr_t caller) { abort(); }
+static void abort_with_message(const char *kind, uintptr_t caller, const uintptr_t *address) { abort(); }
#endif
#if SANITIZER_DEBUG
@@ -132,7 +132,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
INTERFACE void __ubsan_handle_##name##_minimal_abort() { \
uintptr_t caller = GET_CALLER_PC(); \
__ubsan_report_error_fatal(kind, caller, nullptr); \
- abort_with_message(kind, caller); \
+ abort_with_message(kind, caller, nullptr); \
}
#define HANDLER(name, kind) \
@@ -149,7 +149,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
const uintptr_t address) { \
uintptr_t caller = GET_CALLER_PC(); \
__ubsan_report_error_fatal(kind, caller, &address); \
- abort_with_message(kind, caller); \
+ abort_with_message(kind, caller, nullptr); \
}
// A version of a handler that takes a pointer to a value.
>From d92151e22a7cd30aa48fa3aaec2fc40ed5de4849 Mon Sep 17 00:00:00 2001
From: Sharjeel Khan <sharjeelkhan at google.com>
Date: Thu, 7 Aug 2025 00:52:08 +0000
Subject: [PATCH 2/3] Clang Format fix
---
compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index 2295162021f85..f0959fe801169 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -149,7 +149,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
const uintptr_t address) { \
uintptr_t caller = GET_CALLER_PC(); \
__ubsan_report_error_fatal(kind, caller, &address); \
- abort_with_message(kind, caller, nullptr); \
+ abort_with_message(kind, caller, &address); \
}
// A version of a handler that takes a pointer to a value.
>From 222c407698fc424335661d637e4967b6b282c7fe Mon Sep 17 00:00:00 2001
From: Sharjeel Khan <sharjeelkhan at google.com>
Date: Thu, 7 Aug 2025 00:57:37 +0000
Subject: [PATCH 3/3] Actual Clang Format fix
---
compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index f0959fe801169..a2a2e36e8523d 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -97,7 +97,8 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error_fatal, const char *kind,
#if defined(__ANDROID__)
extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
-static void abort_with_message(const char *kind, uintptr_t caller, const uintptr_t *address) {
+static void abort_with_message(const char *kind, uintptr_t caller,
+ const uintptr_t *address) {
char msg_buf[128];
format_msg(kind, caller, address, msg_buf, msg_buf + sizeof(msg_buf));
if (&android_set_abort_message)
@@ -105,7 +106,10 @@ static void abort_with_message(const char *kind, uintptr_t caller, const uintptr
abort();
}
#else
-static void abort_with_message(const char *kind, uintptr_t caller, const uintptr_t *address) { abort(); }
+static void abort_with_message(const char *kind, uintptr_t caller,
+ const uintptr_t *address) {
+ abort();
+}
#endif
#if SANITIZER_DEBUG
More information about the llvm-commits
mailing list