-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[UBSan] [compiler-rt] add preservecc variants of handlers #168643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fmayer
merged 1 commit into
main
from
users/fmayer/spr/ubsan-compiler-rt-add-preservecc-variants-of-handlers-1
Nov 20, 2025
Merged
[UBSan] [compiler-rt] add preservecc variants of handlers #168643
fmayer
merged 1 commit into
main
from
users/fmayer/spr/ubsan-compiler-rt-add-preservecc-variants-of-handlers-1
Nov 20, 2025
+20
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.7
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Florian Mayer (fmayer) ChangesFull diff: https://github.com/llvm/llvm-project/pull/168643.diff 2 Files Affected:
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index a2a2e36e8523d..0a2d6f35a539a 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -89,6 +89,17 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error, const char *kind,
}
}
+SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error_preserve,
+ const char *kind, uintptr_t caller,
+ const uintptr_t *address)
+[[clang::preserve_all]] {
+ // Additional indirecton so the user can override this with their own
+ // preserve_all function. This would allow, e.g., a function that reports the
+ // first error only, so for all subsequent calls we can skip the register save
+ // / restore.
+ __ubsan_report_error(kind, caller, address);
+}
+
SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error_fatal, const char *kind,
uintptr_t caller, const uintptr_t *address) {
// Use another handlers, in case it's already overriden.
@@ -130,6 +141,10 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
#define HANDLER_RECOVER(name, kind) \
INTERFACE void __ubsan_handle_##name##_minimal() { \
__ubsan_report_error(kind, GET_CALLER_PC(), nullptr); \
+ } \
+ INTERFACE void __ubsan_handle_##name##_minimal_preserve() \
+ [[clang::preserve_all]] { \
+ __ubsan_report_error_preserve(kind, GET_CALLER_PC(), nullptr); \
}
#define HANDLER_NORECOVER(name, kind) \
@@ -146,6 +161,10 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
#define HANDLER_RECOVER_PTR(name, kind) \
INTERFACE void __ubsan_handle_##name##_minimal(const uintptr_t address) { \
__ubsan_report_error(kind, GET_CALLER_PC(), &address); \
+ } \
+ INTERFACE void __ubsan_handle_##name##_minimal_preserve( \
+ const uintptr_t address) [[clang::preserve_all]] { \
+ __ubsan_report_error_preserve(kind, GET_CALLER_PC(), &address); \
}
#define HANDLER_NORECOVER_PTR(name, kind) \
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c b/compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c
index abc1073e02073..3c76e5aadc087 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c
@@ -4,6 +4,7 @@
// REQUIRES: x86_64-darwin
// RUN: nm -jgU `%clangxx_min_runtime -fsanitize-minimal-runtime -fsanitize=undefined %s -o %t '-###' 2>&1 | grep "libclang_rt.ubsan_minimal_osx_dynamic.dylib" | sed -e 's/.*"\(.*libclang_rt.ubsan_minimal_osx_dynamic.dylib\)".*/\1/'` | grep "^___ubsan_handle" \
+// RUN: | grep -vE "_minimal_preserve" \
// RUN: | sed 's/_minimal//g' \
// RUN: > %t.minimal.symlist
//
|
🐧 Linux x64 Test Results
|
vitalybuka
approved these changes
Nov 20, 2025
fmayer
added a commit
that referenced
this pull request
Nov 21, 2025
Collaborator
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/22606 Here is the relevant piece of the build log for the reference |
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Nov 21, 2025
…andlers" (#168973) Reverts llvm/llvm-project#168643
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.