re PR sanitizer/77396 (address sanitizer crashes if all static global variables...
authorJakub Jelinek <jakub@redhat.com>
Mon, 5 Sep 2016 19:43:57 +0000 (21:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 5 Sep 2016 19:43:57 +0000 (21:43 +0200)
PR sanitizer/77396
* asan/asan_globals.cc: Cherry-pick upstream r280657.

* g++.dg/asan/pr77396-2.C: New test.

From-SVN: r239998

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/asan/pr77396-2.C [new file with mode: 0644]
libsanitizer/ChangeLog
libsanitizer/asan/asan_globals.cc

index 87e882253820ae1fb9fe82453af5e91a2ba9b8fc..d7640245e26c547110ddd71e58b7583b3d354684 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/77396
+       * g++.dg/asan/pr77396-2.C: New test.
+
 2016-09-05  Uros Bizjak  <ubizjak@gmail.com>
 
        PR rtl-optimization/77452
diff --git a/gcc/testsuite/g++.dg/asan/pr77396-2.C b/gcc/testsuite/g++.dg/asan/pr77396-2.C
new file mode 100644 (file)
index 0000000..0570a14
--- /dev/null
@@ -0,0 +1,12 @@
+// PR sanitizer/77396
+// { dg-do run }
+// { dg-set-target-env-var ASAN_OPTIONS "check_initialization_order=true" }
+
+struct S { S () { asm volatile ("" : : : "memory"); } };
+static S c;
+
+int
+main ()
+{
+  return 0;
+}
index d9eb7fa3bd2f6900a92cf6fc3cf9766e98ba5880..a06ab4de7e75f6fd59a7af3d7937337213318029 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/77396
+       * asan/asan_globals.cc: Cherry-pick upstream r280657.
+
 2016-08-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/71042
index 9c3588b8e081f5101dfb0c67ab231338f985437c..f3531cbd1339fadf2cfffc4432f01e4c399af913 100644 (file)
@@ -248,10 +248,10 @@ void __asan_unregister_globals(__asan_global *globals, uptr n) {
 // initializer can only touch global variables in the same TU.
 void __asan_before_dynamic_init(const char *module_name) {
   if (!flags()->check_initialization_order ||
-      !CanPoisonMemory())
+      !CanPoisonMemory() ||
+      !dynamic_init_globals)
     return;
   bool strict_init_order = flags()->strict_init_order;
-  CHECK(dynamic_init_globals);
   CHECK(module_name);
   CHECK(asan_inited);
   BlockingMutexLock lock(&mu_for_globals);
@@ -274,7 +274,8 @@ void __asan_before_dynamic_init(const char *module_name) {
 // TU are poisoned.  It simply unpoisons all dynamically initialized globals.
 void __asan_after_dynamic_init() {
   if (!flags()->check_initialization_order ||
-      !CanPoisonMemory())
+      !CanPoisonMemory() ||
+      !dynamic_init_globals)
     return;
   CHECK(asan_inited);
   BlockingMutexLock lock(&mu_for_globals);