File tree Expand file tree Collapse file tree 2 files changed +17
-34
lines changed
compiler-rt/test/asan/TestCases Expand file tree Collapse file tree 2 files changed +17
-34
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11// RUN: %clangxx_asan -O0 %s -o %t
2- // RUN: %env_asan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
3- // RUN: %env_asan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2
2+ // RUN: %env_asan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ABORT
3+ // RUN: %env_asan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-RETURN_NULL
44
5- // CHECK1: exceeds maximum supported size
6- // CHECK1: ABORT
5+ // RUN: %clangxx_asan -O0 %s -o %t -DUSER_FUNCTION
6+ // RUN: %env_asan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-RETURN_NULL
77
8- // CHECK2: Success
8+ #if USER_FUNCTION
9+ // On Windows, flags configured through the user-defined function `__asan_default_options`
10+ // are suspected to not always be honored according to GitHub bug:
11+ // https://github.com/llvm/llvm-project/issues/117925
12+ // This test ensures we do not regress on `allocator_may_return_null` specifically.
13+ extern " C" __declspec(dllexport) extern const char *__asan_default_options () {
14+ return " allocator_may_return_null=1" ;
15+ }
16+ #endif
917
1018#include < cstdint>
11- #include < cstdio>
1219#include < cstdlib>
1320#include < limits>
1421
@@ -17,7 +24,10 @@ int main() {
1724 // terminate the program unless `allocator_may_return_null` is set.
1825 size_t max = std::numeric_limits<size_t >::max ();
1926
27+ // CHECK-ABORT: exceeds maximum supported size
28+ // CHECK-ABORT: ABORT
2029 free (malloc (max));
21- printf (" Success" );
30+
31+ printf (" Success" ); // CHECK-RETURN_NULL: Success
2232 return 0 ;
2333}
You can’t perform that action at this time.
0 commit comments