This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by kubamracek on Oct 21 2016, 5:06 PM.

Details

Reviewers
kcc
dvyukov
Summary

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.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 75514.Oct 21 2016, 5:06 PM
kubamracek retitled this revision from to [tsan] Unwind the shadow stack in __tsan_func_exit() if the top of the shadow stack doesn’t match.
kubamracek updated this object.
kubamracek added reviewers: dvyukov, kcc.
kubamracek set the repository for this revision to rL LLVM.
kubamracek added a project: Restricted Project.
kubamracek added subscribers: zaks.anna, llvm-commits.