[PATCH] D25889: [tsan] Unwind the shadow stack in __tsan_func_exit() if the top of the shadow stack doesn’t match

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 17:06:47 PDT 2016


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, kcc.
kubabrecka added subscribers: zaks.anna, llvm-commits.
kubabrecka set the repository for this revision to rL LLVM.
kubabrecka added a project: Sanitizers.

C++ exceptions currently cause the shadow stack to get corrupt, because a PC can remain on the stack when the exception mechanism skips a calls to __tsan_func_exit.  Besides producing wrong backtraces in reports, this also causes enormous memory usage growth in some cases.

Instead of handling exceptions at the instrumentation level, this patch tries to “fix” the shadow stack when it detects that when calling __tsan_func_exit, the top of the stack contains something else than what __tsan_func_entry inserted there.

Still WIP, this fails some tests (LLVM instrumentation tests, Go test and unit tests) and is missing a testcase.


Repository:
  rL LLVM

https://reviews.llvm.org/D25889

Files:
  lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
  projects/compiler-rt/lib/tsan/rtl/tsan_interface.h
  projects/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc
  projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc
  projects/compiler-rt/lib/tsan/rtl/tsan_interface_inl.h
  projects/compiler-rt/lib/tsan/rtl/tsan_interface_java.cc
  projects/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
  projects/compiler-rt/lib/tsan/rtl/tsan_rtl.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25889.75514.patch
Type: text/x-patch
Size: 6729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161022/7ba6a8f0/attachment.bin>


More information about the llvm-commits mailing list