diff options
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_interceptors.cc | 4 | ||||
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc | 5 | ||||
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_interface_java.cc | 3 | ||||
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc | 16 | 
5 files changed, 19 insertions, 10 deletions
| diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc index ef94b908ac5..ae7ad6dc67b 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc @@ -181,8 +181,7 @@ ScopedInterceptor::~ScopedInterceptor() {      StatInc(thr, StatInt_##func); \      const uptr caller_pc = GET_CALLER_PC(); \      ScopedInterceptor si(thr, #func, caller_pc); \ -    const uptr pc = __sanitizer::StackTrace::GetPreviousInstructionPc( \ -        __sanitizer::StackTrace::GetCurrentPc()); \ +    const uptr pc = __sanitizer::StackTrace::GetCurrentPc(); \      (void)pc; \  /**/ @@ -1882,6 +1881,7 @@ void ProcessPendingSignals(ThreadState *thr) {            uptr pc = signal->sigaction ?                (uptr)sigactions[sig].sa_sigaction :                (uptr)sigactions[sig].sa_handler; +          pc += 1;  // return address is expected, OutputReport() will undo this            stack.Init(&pc, 1);            ThreadRegistryLock l(ctx->thread_registry);            ScopedReport rep(ReportTypeErrnoInSignal); diff --git a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc index 04b4b455d15..36a7b5372b0 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc @@ -13,6 +13,7 @@  #include "sanitizer_common/sanitizer_libc.h"  #include "sanitizer_common/sanitizer_internal_defs.h"  #include "sanitizer_common/sanitizer_placement_new.h" +#include "sanitizer_common/sanitizer_stacktrace.h"  #include "tsan_interface_ann.h"  #include "tsan_mutex.h"  #include "tsan_report.h" @@ -229,12 +230,12 @@ using namespace __tsan;  // NOLINT  extern "C" {  void INTERFACE_ATTRIBUTE AnnotateHappensBefore(char *f, int l, uptr addr) {    SCOPED_ANNOTATION(AnnotateHappensBefore); -  Release(cur_thread(), CALLERPC, addr); +  Release(cur_thread(), pc, addr);  }  void INTERFACE_ATTRIBUTE AnnotateHappensAfter(char *f, int l, uptr addr) {    SCOPED_ANNOTATION(AnnotateHappensAfter); -  Acquire(cur_thread(), CALLERPC, addr); +  Acquire(cur_thread(), pc, addr);  }  void INTERFACE_ATTRIBUTE AnnotateCondVarSignal(char *f, int l, uptr cv) { diff --git a/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc b/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc index eb225931d39..f635660aa6b 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc @@ -30,7 +30,6 @@ using namespace __tsan;  // NOLINT  #define SCOPED_ATOMIC(func, ...) \      const uptr callpc = (uptr)__builtin_return_address(0); \      uptr pc = __sanitizer::StackTrace::GetCurrentPc(); \ -    pc = __sanitizer::StackTrace::GetPreviousInstructionPc(pc); \      mo = ConvertOrder(mo); \      mo = flags()->force_seq_cst_atomics ? (morder)mo_seq_cst : mo; \      ThreadState *const thr = cur_thread(); \ diff --git a/compiler-rt/lib/tsan/rtl/tsan_interface_java.cc b/compiler-rt/lib/tsan/rtl/tsan_interface_java.cc index 71e0747c364..358fd15ddef 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interface_java.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_interface_java.cc @@ -17,6 +17,7 @@  #include "sanitizer_common/sanitizer_internal_defs.h"  #include "sanitizer_common/sanitizer_common.h"  #include "sanitizer_common/sanitizer_placement_new.h" +#include "sanitizer_common/sanitizer_stacktrace.h"  using namespace __tsan;  // NOLINT @@ -157,7 +158,7 @@ SyncVar* GetAndRemoveJavaSync(ThreadState *thr, uptr pc, uptr addr) {  #define SCOPED_JAVA_FUNC(func) \    ThreadState *thr = cur_thread(); \    const uptr caller_pc = GET_CALLER_PC(); \ -  const uptr pc = (uptr)&func; \ +  const uptr pc = __sanitizer::StackTrace::GetCurrentPc(); \    (void)pc; \    ScopedJavaFunc scoped(thr, caller_pc); \  /**/ diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc index 63435cf6494..94419ce9c2b 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc @@ -106,17 +106,25 @@ static ReportStack *SymbolizeStack(const StackTrace& trace) {      return 0;    ReportStack *stack = 0;    for (uptr si = 0; si < trace.Size(); si++) { +    const uptr pc = trace.Get(si); +#ifndef TSAN_GO      // We obtain the return address, that is, address of the next instruction,      // so offset it by 1 byte. -    bool is_last = (si == trace.Size() - 1); -    ReportStack *ent = SymbolizeCode(trace.Get(si) - !is_last); +    const uptr pc1 = __sanitizer::StackTrace::GetPreviousInstructionPc(pc); +#else +    // FIXME(dvyukov): Go sometimes uses address of a function as top pc. +    uptr pc1 = pc; +    if (si != trace.Size() - 1) +      pc1 -= 1; +#endif +    ReportStack *ent = SymbolizeCode(pc1);      CHECK_NE(ent, 0);      ReportStack *last = ent;      while (last->next) { -      last->pc += !is_last; +      last->pc = pc;  // restore original pc for report        last = last->next;      } -    last->pc += !is_last; +    last->pc = pc;  // restore original pc for report      last->next = stack;      stack = ent;    } | 

