This is an archive of the discontinued LLVM Phabricator instance.

[msan] Fix infinite recursion when _Unwind_Backtrace calls memcpy
ClosedPublic

Authored by foad on Jun 26 2015, 1:53 AM.

Details

Summary

On PPC64, half the msan tests fail with an infinite recursion through
GetStackTrace like this:

#0 msan::GetStackTrace
#1
msan_memcpy
#2 ?? () from /lib64/libgcc_s.so.1
#3 ?? () from /lib64/libgcc_s.so.1
#4 _Unwind_Backtrace
#5 sanitizer::BufferedStackTrace::SlowUnwindStack
#6
sanitizer::BufferedStackTrace::Unwind
#7 msan::GetStackTrace
#8
interceptor_calloc
#9 _dl_allocate_tls
#10 pthread_create@@GLIBC_2.17
#11 __interceptor_pthread_create
#12 main

The problem is that we call _Unwind_Backtrace to get a stack trace; but
_Unwind_Backtrace calls memcpy, which we intercept and try to get
another stack trace.

This patch fixes it in __msan_memcpy by skipping the stack trace if
IsInSymbolizer(). This works because GetStackTrace already creates a
SymbolizerScope to "block reports from our interceptors during
_Unwind_Backtrace".

Diff Detail

Event Timeline

foad updated this revision to Diff 28547.Jun 26 2015, 1:53 AM
foad retitled this revision from to [msan] Fix infinite recursion when _Unwind_Backtrace calls memcpy.
foad updated this object.
foad edited the test plan for this revision. (Show Details)
foad added reviewers: samsonov, eugenis, wschmidt.
foad added a subscriber: Unknown Object (MLST).
eugenis accepted this revision.Jun 26 2015, 11:46 AM
eugenis edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jun 26 2015, 11:46 AM
foad closed this revision.Jun 27 2015, 1:39 AM