-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Darwin][ASan][Test] Create a noinlined wrapper function for reliable suppression in test. #131247
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
[Darwin][ASan][Test] Create a noinlined wrapper function for reliable suppression in test. #131247
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Paddy McDonald (padriff) ChangesCFStringCreateWithBytes may not always appear on stack due to optimizations. Create a wrapper function for the purposes of testing suppression files that will always appear on stack for test stability. Also necessary to disable leaks to pass on Apple Silicon. rdar://144800068 Full diff: https://github.com/llvm/llvm-project/pull/131247.diff 1 Files Affected:
diff --git a/compiler-rt/test/asan/TestCases/Darwin/suppressions-sandbox.cpp b/compiler-rt/test/asan/TestCases/Darwin/suppressions-sandbox.cpp
index 966f21346e4fe..50dfd1e2e332b 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/suppressions-sandbox.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/suppressions-sandbox.cpp
@@ -3,8 +3,8 @@
// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
// Check that suppressing a function name works within a no-fork sandbox
-// RUN: echo "interceptor_via_fun:CFStringCreateWithBytes" > %t.supp
-// RUN: %env_asan_opts=suppressions='"%t.supp"' \
+// RUN: echo "interceptor_via_fun:createCFString" > %t.supp
+// RUN: %env_asan_opts=suppressions='"%t.supp"':verbostiy=1: \
// RUN: sandbox-exec -p '(version 1)(allow default)(deny process-fork)' \
// RUN: %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
@@ -13,12 +13,17 @@
#include <CoreFoundation/CoreFoundation.h>
+// Use a noinline + disable_tail_calls wrapper function to suppress to stabilize test.
+__attribute__((noinline)) __attribute__((disable_tail_calls)) CFStringRef
+createCFString(const unsigned char *bytes, CFIndex length) {
+ return CFStringCreateWithBytes(kCFAllocatorDefault, bytes, length,
+ kCFStringEncodingUTF8, FALSE);
+}
+
int main() {
char *a = (char *)malloc(6);
strcpy(a, "hello");
- CFStringRef str =
- CFStringCreateWithBytes(kCFAllocatorDefault, (unsigned char *)a, 10,
- kCFStringEncodingUTF8, FALSE); // BOOM
+ CFStringRef str = createCFString((unsigned char *)a, 10); // BOOM
fprintf(stderr, "Ignored.\n");
free(a);
CFRelease(str);
|
compiler-rt/test/asan/TestCases/Darwin/suppressions-sandbox.cpp
Outdated
Show resolved
Hide resolved
@@ -13,12 +13,17 @@ | |||
|
|||
#include <CoreFoundation/CoreFoundation.h> | |||
|
|||
// Use a noinline + disable_tail_calls wrapper function to suppress to stabilize test. | |||
__attribute__((noinline)) __attribute__((disable_tail_calls)) CFStringRef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: __attribute__((noinline, disable_tail_calls))
also this feels a bit like overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two optimizations that could break the test are inlining of the function and if the function were optimized to tail call to the callee. Admittedly I don't think the current optimizer will add a tail call as the callee is external to the binary, but if we are explicitly disabling one that can break it then shouldn't we do both?
approved, but please address nits |
… suppression in test. CFStringCreateWithBytes may not always appear on stack due to optimizations. Create a wrapper function for the purposes of testing suppression files that will always appear on stack for test stability. Also necessary to disable leaks to pass on Apple Silicon. rdar://144800068
e7e01c3
to
f3f7543
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with nits, thanks!
compiler-rt/test/asan/TestCases/Darwin/suppressions-sandbox.cpp
Outdated
Show resolved
Hide resolved
compiler-rt/test/asan/TestCases/Darwin/suppressions-sandbox.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Julian Lettner <[email protected]>
Co-authored-by: Julian Lettner <[email protected]>
@padriff Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
this seems to have broken the test on x86-64 macs:
the test logs are not very helpful though... |
also started failing at https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/3852/ with this PR in the blamelist, can we revert this? |
…reliable suppression in test. (#131247)" This reverts commit 78f74f6. Breaks the test on x86-64 mac, e.g. https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/3852/.
I've reverted this in a65cbc4, feel free to reland once you've figured out the x86-64 issue also I'm surprised this is necessary given the test uses -O0 |
@aeubanks - thanks, I was working on a fix yesterday to address this. The issue is related to the FIXME comment in DemangleCXXABI in compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp. The tail call optimization that breaks the test on AS is in the external code rather than in the test code, so the -O0 doesn't impact that. Updated PR which also moves the suppression to a non-sanitized dylib |
CFStringCreateWithBytes may not always appear on stack due to optimizations. Create a wrapper function for the purposes of testing suppression files that will always appear on stack for test stability.
Also necessary to disable leaks to pass on Apple Silicon.
rdar://144800068