[HWASAN] Fix verbose_threads
authorVitaly Buka <vitalybuka@google.com>
Sat, 10 Jun 2023 03:39:15 +0000 (20:39 -0700)
committerVitaly Buka <vitalybuka@google.com>
Sat, 10 Jun 2023 03:56:23 +0000 (20:56 -0700)
Looks like D104248 acidentally moved the code.

compiler-rt/lib/hwasan/hwasan_thread.cpp
compiler-rt/test/hwasan/TestCases/verbose_threads.c

index a97b8e55f37cba055f641cdc9423d1ab2c7e7ca9..ce36547580e6e60ccdaaa6bfb697d50c47ebac22 100644 (file)
@@ -59,6 +59,15 @@ void Thread::Init(uptr stack_buffer_start, uptr stack_buffer_size,
   InitStackAndTls(state);
   dtls_ = DTLS_Get();
   AllocatorThreadStart(allocator_cache());
+
+  if (flags()->verbose_threads) {
+    if (IsMainThread()) {
+      Printf("sizeof(Thread): %zd sizeof(HeapRB): %zd sizeof(StackRB): %zd\n",
+             sizeof(Thread), heap_allocations_->SizeInBytes(),
+             stack_allocations_->size() * sizeof(uptr));
+    }
+    Print("Creating  : ");
+  }
 }
 
 void Thread::InitStackRingBuffer(uptr stack_buffer_start,
@@ -80,15 +89,6 @@ void Thread::InitStackRingBuffer(uptr stack_buffer_start,
     CHECK(MemIsApp(stack_bottom_));
     CHECK(MemIsApp(stack_top_ - 1));
   }
-
-  if (flags()->verbose_threads) {
-    if (IsMainThread()) {
-      Printf("sizeof(Thread): %zd sizeof(HeapRB): %zd sizeof(StackRB): %zd\n",
-             sizeof(Thread), heap_allocations_->SizeInBytes(),
-             stack_allocations_->size() * sizeof(uptr));
-    }
-    Print("Creating  : ");
-  }
 }
 
 void Thread::ClearShadowForThreadStackAndTLS() {
index 85afb4e9eae358c2bfb15ca9d3d46286a6553cbc..951bdc5dce55688f89b6d74094ca88b374df0b15 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=verbose_threads=1 %run %t 2>&1 | FileCheck %s
+// RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=verbose_threads=1 %run %t 2>&1 | FileCheck %s --implicit-check-not=0x000000000000
 // REQUIRES: stable-runtime
 
 #include <pthread.h>
@@ -11,8 +11,8 @@
 // CHECK: Creating : T0 0x[[#%x,T0:]] stack: [0x[[#%x,SB0:]],0x[[#%x,SE0:]]) sz: [[#]] tls: [0x[[#%x,TB0:]],0x[[#%x,TE0:]])
 // CHECK: Creating : T1 0x[[#%x,T1:]] stack: [0x[[#%x,SB1:]],0x[[#%x,SE1:]]) sz: [[#]] tls: [0x[[#%x,TB1:]],0x[[#%x,TE1:]])
 // CHECK: Creating : T2 0x[[#%x,T2:]] stack: [0x[[#%x,SB2:]],0x[[#%x,SE2:]]) sz: [[#]] tls: [0x[[#%x,TB2:]],0x[[#%x,TE2:]])
-// CHECK: Destroying: T2 0x[[#T2]] stack: [0x[[#%x,SB2:]],0x[[#%x,SE2:]]) sz: [[#]] tls: [0x[[#%x,TB2:]],0x[[#%x,TE2:]])
-// CHECK: Destroying: T1 0x[[#T1]] stack: [0x[[#%x,SB1:]],0x[[#%x,SE1:]]) sz: [[#]] tls: [0x[[#%x,TB1:]],0x[[#%x,TE1:]])
+// CHECK: Destroying: T2 0x[[#T2]] stack: [0x[[#SB2]],0x[[#SE2]]) sz: [[#]] tls: [0x[[#TB2]],0x[[#TE2]])
+// CHECK: Destroying: T1 0x[[#T1]] stack: [0x[[#SB1]],0x[[#SE1]]) sz: [[#]] tls: [0x[[#TB1]],0x[[#TE1]])
 
 void *Empty(void *arg) {
   if (arg) return NULL;