diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp --- a/compiler-rt/lib/msan/msan.cpp +++ b/compiler-rt/lib/msan/msan.cpp @@ -101,7 +101,6 @@ // Array of stack origins. // FIXME: make it resizable. static const uptr kNumStackOriginDescrs = 1024 * 1024; -static const char *StackOriginDescr[kNumStackOriginDescrs]; static uptr StackOriginPC[kNumStackOriginDescrs]; static atomic_uint32_t NumStackOriginDescrs; @@ -289,7 +288,7 @@ const char *GetStackOriginDescr(u32 id, uptr *pc) { CHECK_LT(id, kNumStackOriginDescrs); if (pc) *pc = StackOriginPC[id]; - return StackOriginDescr[id]; + return nullptr; } u32 ChainOrigin(u32 id, StackTrace *stack) { @@ -601,7 +600,6 @@ if (id == first_timer) { u32 idx = atomic_fetch_add(&NumStackOriginDescrs, 1, memory_order_relaxed); CHECK_LT(idx, kNumStackOriginDescrs); - StackOriginDescr[idx] = descr + 4; #if SANITIZER_PPC64V1 // On PowerPC64 ELFv1, the address of a function actually points to a // three-doubleword data structure with the first field containing diff --git a/compiler-rt/lib/msan/msan_report.cpp b/compiler-rt/lib/msan/msan_report.cpp --- a/compiler-rt/lib/msan/msan_report.cpp +++ b/compiler-rt/lib/msan/msan_report.cpp @@ -35,23 +35,24 @@ }; static void DescribeStackOrigin(const char *so, uptr pc) { + const char* function_name = "kUNKNOWN_FUNCTIONk"; + if (pc) { + // For some reason function address in LLVM IR is 1 less then the address + // of the first instruction. + pc = StackTrace::GetNextInstructionPc(pc); + SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc); + // TODO: Does not work for SANITIZER_NETBSD + function_name = frame->info.function; + } Decorator d; - char *s = internal_strdup(so); - char *sep = internal_strchr(s, '@'); - CHECK(sep); - *sep = '\0'; Printf("%s", d.Origin()); Printf( " %sUninitialized value was created by an allocation of '%s%s%s'" " in the stack frame of function '%s%s%s'%s\n", - d.Origin(), d.Name(), s, d.Origin(), d.Name(), sep + 1, d.Origin(), - d.Default()); - InternalFree(s); + d.Origin(), d.Name(), "kUNKNOWN_VARIABLEk", d.Origin(), d.Name(), + function_name, d.Origin(), d.Default()); if (pc) { - // For some reason function address in LLVM IR is 1 less then the address - // of the first instruction. - pc = StackTrace::GetNextInstructionPc(pc); StackTrace(&pc, 1).Print(); } } diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -3875,7 +3875,7 @@ // It will be printed by the run-time if stack-originated UMR is found. // The first 4 bytes of the string are set to '----' and will be replaced // by __msan_va_arg_overflow_size_tls at the first call. - StackDescription << "----" << I.getName() << "@" << F.getName(); + StackDescription << "----"; return createPrivateNonConstGlobalForString(*F.getParent(), StackDescription.str()); }