tsan: fix Java heap block begin in reports
We currently use a wrong value for heap block
(only works for C++, but not for Java).
Use the correct value (we already computed it before, just forgot to use).
Depends on D114593.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D114595
GitOrigin-RevId: b584741d06ef01b7497d58776e225aa189528968
diff --git a/lib/tsan/rtl/tsan_rtl_report.cpp b/lib/tsan/rtl/tsan_rtl_report.cpp
index 811695d..f332a6a 100644
--- a/lib/tsan/rtl/tsan_rtl_report.cpp
+++ b/lib/tsan/rtl/tsan_rtl_report.cpp
@@ -346,7 +346,7 @@
ThreadContext *tctx = FindThreadByTidLocked(b->tid);
auto *loc = New<ReportLocation>();
loc->type = ReportLocationHeap;
- loc->heap_chunk_start = (uptr)allocator()->GetBlockBegin((void *)addr);
+ loc->heap_chunk_start = block_begin;
loc->heap_chunk_size = b->siz;
loc->external_tag = b->tag;
loc->tid = tctx ? tctx->tid : b->tid;
diff --git a/test/tsan/java_symbolization.cpp b/test/tsan/java_symbolization.cpp
index 50f7f49..534dc5d 100644
--- a/test/tsan/java_symbolization.cpp
+++ b/test/tsan/java_symbolization.cpp
@@ -39,6 +39,7 @@
const int kBlockSize = 32;
__tsan_func_entry(3456 | kExternalPCBit);
__tsan_java_alloc(jheap, kBlockSize);
+ print_address("addr:", 2, jheap, jheap + 16);
__tsan_func_exit();
pthread_t th;
pthread_create(&th, 0, Thread, (void*)jheap);
@@ -52,18 +53,19 @@
return __tsan_java_fini();
}
+// CHECK: addr:[[BLOCK:0x[0-9,a-f]+]] [[ADDR:0x[0-9,a-f]+]]
// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Write
+// CHECK: Write of size 1 at [[ADDR]] by thread T1:
// CHECK: #0 MyInnerFunc MyInnerFile.java:1234:56
// CHECK: #1 MyOuterFunc MyOuterFile.java:4321:65
// CHECK: #2 Caller1 CallerFile.java:111:22
// CHECK: #3 Caller2 CallerFile.java:333:44
-// CHECK: Previous write
+// CHECK: Previous write of size 1 at [[ADDR]] by main thread:
// CHECK: #0 MyInnerFunc MyInnerFile.java:1234:56
// CHECK: #1 MyOuterFunc MyOuterFile.java:4321:65
// CHECK: #2 Caller1 CallerFile.java:111:22
// CHECK: #3 Caller2 CallerFile.java:333:44
-// CHECK: Location is heap block of size 32 at {{.*}} allocated by main thread:
+// CHECK: Location is heap block of size 32 at [[BLOCK]] allocated by main thread:
// CHECK: #0 Allocer1 Alloc.java:11:222
// CHECK: #1 Allocer2 Alloc.java:33:444
// CHECK: DONE