From 0b622f1d6480422f4b3f31737707e2126dc0034a Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 4 Nov 2014 21:26:56 +0000 Subject: [PATCH] Correct the usage of DataInfo structure in TSan llvm-svn: 221297 --- .../lib/sanitizer_common/sanitizer_symbolizer.h | 12 +++++++++++- .../sanitizer_symbolizer_posix_libcdep.cc | 3 +-- compiler-rt/lib/tsan/rtl/tsan_symbolize.cc | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h index a0228ff9fbf3..82093e45420b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h @@ -61,13 +61,23 @@ struct AddressInfo { } }; +// For now, DataInfo is used to describe global variable. struct DataInfo { - uptr address; char *module; uptr module_offset; char *name; uptr start; uptr size; + + DataInfo() { + internal_memset(this, 0, sizeof(DataInfo)); + } + + void Clear() { + InternalFree(module); + InternalFree(name); + internal_memset(this, 0, sizeof(DataInfo)); + } }; class Symbolizer { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc index 636fdeae82a9..eb2b707ec3c6 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc @@ -589,8 +589,7 @@ class POSIXSymbolizer : public Symbolizer { return false; const char *module_name = module->full_name(); uptr module_offset = addr - module->base_address(); - internal_memset(info, 0, sizeof(*info)); - info->address = addr; + info->Clear(); info->module = internal_strdup(module_name); info->module_offset = module_offset; // First, try to use libbacktrace symbolizer (if it's available). diff --git a/compiler-rt/lib/tsan/rtl/tsan_symbolize.cc b/compiler-rt/lib/tsan/rtl/tsan_symbolize.cc index 7bb2dec5e5d8..50eca27a4bfb 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_symbolize.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_symbolize.cc @@ -110,6 +110,7 @@ ReportLocation *SymbolizeData(uptr addr) { ent->name = internal_strdup(info.name); ent->addr = info.start; ent->size = info.size; + info.Clear(); return ent; }