-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[test][asan] Check for order of DynInitPoison #101584
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
[test][asan] Check for order of DynInitPoison #101584
Conversation
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesAlso make sure we have dynamic init variables with any Full diff: https://github.com/llvm/llvm-project/pull/101584.diff 2 Files Affected:
diff --git a/compiler-rt/test/asan/TestCases/Helpers/initialization-nobug-extra.cpp b/compiler-rt/test/asan/TestCases/Helpers/initialization-nobug-extra.cpp
index 886165affd760..0ce5359b405d0 100644
--- a/compiler-rt/test/asan/TestCases/Helpers/initialization-nobug-extra.cpp
+++ b/compiler-rt/test/asan/TestCases/Helpers/initialization-nobug-extra.cpp
@@ -1,9 +1,9 @@
// Linker initialized:
int getAB();
-static int ab = getAB();
+int ab = getAB();
// Function local statics:
int countCalls();
-static int one = countCalls();
+int one = countCalls();
// Trivial constructor, non-trivial destructor:
int getStructWithDtorValue();
-static int val = getStructWithDtorValue();
+int val = getStructWithDtorValue();
diff --git a/compiler-rt/test/asan/TestCases/initialization-nobug.cpp b/compiler-rt/test/asan/TestCases/initialization-nobug.cpp
index d4dc855148ad3..0b8fca3dee8b3 100644
--- a/compiler-rt/test/asan/TestCases/initialization-nobug.cpp
+++ b/compiler-rt/test/asan/TestCases/initialization-nobug.cpp
@@ -1,19 +1,16 @@
// A collection of various initializers which shouldn't trip up initialization
// order checking. If successful, this will just return 0.
-// RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-nobug-extra.cpp -o %t
-// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
-// RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-nobug-extra.cpp -o %t
-// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
-// RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-nobug-extra.cpp -o %t
-// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
-// RUN: %clangxx_asan -O3 %s %p/Helpers/initialization-nobug-extra.cpp -o %t
-// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
+// RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit"
+// RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit"
+// RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit"
+// RUN: %clangxx_asan -O3 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit"
// Simple access:
// Make sure that accessing a global in the same TU is safe
bool condition = true;
+__attribute__((noinline, weak))
int initializeSameTU() {
return condition ? 0x2a : 052;
}
@@ -46,3 +43,7 @@ StructWithDtor struct_with_dtor;
int getStructWithDtorValue() { return struct_with_dtor.value; }
int main() { return 0; }
+
+
+// CHECK: DynInitPoison module: {{.*}}initialization-nobug.cpp
+// CHECK: DynInitPoison module: {{.*}}initialization-nobug-extra.cpp
|
Created using spr 1.3.4 [skip ci]
✅ With the latest revision this PR passed the C/C++ code formatter. |
These new tests seem to fail on mingw targets - see https://github.com/mstorsjo/llvm-mingw/actions/runs/10223903341/job/28296084101 for a failed run. It looks like the output is
while we expect them to come in the reverse order. So I guess that sounds like a real bug on this target (CC @alvinhochun) - I guess we'll need to XFAIL this target in the test to keep the testsuite running though. |
This looks like the test is expecting the static initialization to be done in a specific order (first |
Thanks! So if we could make the test tolerate these two lines in any order ( |
Edit: Rechecked that |
Of cause we don't care about particular order of DynInitPoison. Thanks! |
The test is intended to check the order of modules in DynInitPoison, only relative to DynInitUnpoison. Folloup to #101584
Thanks for the quick fix! |
Also make sure we have dynamic init variables with any
-O
.