[MSan] Fixup for r206983: MsanThread may be unavailable in signal handler: signals may be raised while thread is being destroyed

llvm-svn: 208250
This commit is contained in:
Alexey Samsonov 2014-05-07 21:23:12 +00:00
parent df6860279e
commit 2fccdfbe70
2 changed files with 10 additions and 3 deletions

View File

@ -237,7 +237,8 @@ const char *GetOriginDescrIfStack(u32 id, uptr *pc) {
}
u32 ChainOrigin(u32 id, StackTrace *stack) {
if (GetCurrentThread()->InSignalHandler())
MsanThread *t = GetCurrentThread();
if (t && t->InSignalHandler())
return id;
uptr idx = Min(stack->size, kStackTraceMax - 1);
stack->trace[idx] = TRACE_MAKE_CHAINED(id);

View File

@ -982,8 +982,14 @@ INTERCEPTOR(int, getrusage, int who, void *usage) {
class SignalHandlerScope {
public:
SignalHandlerScope() { GetCurrentThread()->EnterSignalHandler(); }
~SignalHandlerScope() { GetCurrentThread()->LeaveSignalHandler(); }
SignalHandlerScope() {
if (MsanThread *t = GetCurrentThread())
t->EnterSignalHandler();
}
~SignalHandlerScope() {
if (MsanThread *t = GetCurrentThread())
t->LeaveSignalHandler();
}
};
// sigactions_mu guarantees atomicity of sigaction() and signal() calls.