1 | // Test the ignorelist functionality of ASan |
---|---|
2 | |
3 | // RUN: echo "fun:*brokenFunction*" > %tmp |
4 | // RUN: echo "global:*badGlobal*" >> %tmp |
5 | // RUN: echo "src:*ignorelist-extra.cpp" >> %tmp |
6 | // RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O0 %s -o %t \ |
7 | // RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1 |
8 | // RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O1 %s -o %t \ |
9 | // RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1 |
10 | // RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O2 %s -o %t \ |
11 | // RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1 |
12 | // RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O3 %s -o %t \ |
13 | // RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1 |
14 | |
15 | // badGlobal is accessed improperly, but we ignorelisted it. Align |
16 | // it to make sure memory past the end of badGlobal will be in |
17 | // the same page. |
18 | |
19 | // XFAIL: msvc |
20 | #include "defines.h" |
21 | ATTRIBUTE_ALIGNED(16) int badGlobal; |
22 | int readBadGlobal() { |
23 | return (&badGlobal)[1]; |
24 | } |
25 | |
26 | // A function which is broken, but excluded in the ignorelist. |
27 | int brokenFunction(int argc) { |
28 | char x[10] = {0}; |
29 | return x[argc * 10]; // BOOM |
30 | } |
31 | |
32 | // This function is defined in Helpers/ignorelist-extra.cpp, a source file which |
33 | // is ignorelisted by name |
34 | int externalBrokenFunction(int x); |
35 | |
36 | int main(int argc, char **argv) { |
37 | brokenFunction(argc); |
38 | int x = readBadGlobal(); |
39 | externalBrokenFunction(x: argc); |
40 | return 0; |
41 | } |
42 |