<div dir="ltr">Hi Vitaly,<div>We are seeing a bot failure with this commit.  The particular bot which caught this error takes quite some time to run and this was bundled with around 50 other commits so I apologize for the amount of time it took to get the error to you.  The bot failure can be seen here:</div><div><br></div><div><a href="http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_build/5097/">http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_build/5097/</a><br></div><div><br></div><div>I have attached a reproducer to this email and here is the command line invocation used to reproduce the issue:</div><div><br></div><div><path to compiler built on r314041>/bin/clang++  -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all -fsanitize-address-use-after-scope -fcolor-diagnostics -O2 -g  -fno-exceptions -fno-rtti -o /dev/null -c BinaryStreamError.ii<br></div><div><br></div><div>This bot has been broken for almost 5 days now (this was my fault as it took so much time to reproduce the issue) so if you could have a look and get a patch up as soon as possible it would be greatly appreciated.</div><div><br></div><div>Respectfully,</div><div>Mike Edwards</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 22, 2017 at 3:57 PM, Vitaly Buka via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: vitalybuka<br>
Date: Fri Sep 22 15:57:48 2017<br>
New Revision: 314041<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=314041&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=314041&view=rev</a><br>
Log:<br>
[lsan] Deadly signal handler for lsan<br>
<br>
Summary: Part of <a href="https://github.com/google/sanitizers/issues/637" rel="noreferrer" target="_blank">https://github.com/google/<wbr>sanitizers/issues/637</a><br>
<br>
Reviewers: eugenis, alekseyshl<br>
<br>
Subscribers: llvm-commits, dberris, kubamracek, krytarowski<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D37608" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D37608</a><br>
<br>
Modified:<br>
    compiler-rt/trunk/lib/lsan/<wbr>lsan.cc<br>
    compiler-rt/trunk/lib/lsan/<wbr>lsan_interceptors.cc<br>
    compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common.h<br>
    compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common_libcdep.cc<br>
    compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/allow_user_segv.cc<br>
    compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/assert.cc<br>
    compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/ill.cc<br>
    compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/dedup_token_length_test.<wbr>cc<br>
    compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/dump_instruction_bytes.<wbr>cc<br>
    compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/fpe.cc<br>
    compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/sanitizer_set_report_fd_<wbr>test.cc<br>
<br>
Modified: compiler-rt/trunk/lib/lsan/<wbr>lsan.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/lib/<wbr>lsan/lsan.cc?rev=314041&r1=<wbr>314040&r2=314041&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/lib/lsan/<wbr>lsan.cc (original)<br>
+++ compiler-rt/trunk/lib/lsan/<wbr>lsan.cc Fri Sep 22 15:57:48 2017<br>
@@ -65,6 +65,18 @@ static void InitializeFlags() {<br>
   if (common_flags()->help) parser.PrintFlagDescriptions()<wbr>;<br>
 }<br>
<br>
+static void OnStackUnwind(const SignalContext &sig, const void *,<br>
+                          BufferedStackTrace *stack) {<br>
+  GetStackTraceWithPcBpAndContex<wbr>t(stack, kStackTraceMax, sig.pc, sig.bp,<br>
+                                  sig.context,<br>
+                                  common_flags()->fast_unwind_<wbr>on_fatal);<br>
+}<br>
+<br>
+void LsanOnDeadlySignal(int signo, void *siginfo, void *context) {<br>
+  HandleDeadlySignal(siginfo, context, GetCurrentThread(), &OnStackUnwind,<br>
+                     nullptr);<br>
+}<br>
+<br>
 extern "C" void __lsan_init() {<br>
   CHECK(!lsan_init_is_running);<br>
   if (lsan_inited)<br>
@@ -80,6 +92,7 @@ extern "C" void __lsan_init() {<br>
   InitTlsSize();<br>
   InitializeInterceptors();<br>
   InitializeThreadRegistry();<br>
+  InstallDeadlySignalHandlers(<wbr>LsanOnDeadlySignal);<br>
   u32 tid = ThreadCreate(0, 0, true);<br>
   CHECK_EQ(tid, 0);<br>
   ThreadStart(tid, GetTid());<br>
<br>
Modified: compiler-rt/trunk/lib/lsan/<wbr>lsan_interceptors.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_interceptors.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/lib/<wbr>lsan/lsan_interceptors.cc?rev=<wbr>314041&r1=314040&r2=314041&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/lib/lsan/<wbr>lsan_interceptors.cc (original)<br>
+++ compiler-rt/trunk/lib/lsan/<wbr>lsan_interceptors.cc Fri Sep 22 15:57:48 2017<br>
@@ -401,9 +401,14 @@ INTERCEPTOR(void, _exit, int status) {<br>
   REAL(_exit)(status);<br>
 }<br>
<br>
+#define COMMON_INTERCEPT_FUNCTION(<wbr>name) INTERCEPT_FUNCTION(name)<br>
+#include "sanitizer_common/sanitizer_<wbr>signal_interceptors.inc"<br>
+<br>
 namespace __lsan {<br>
<br>
 void InitializeInterceptors() {<br>
+  InitializeSignalInterceptors()<wbr>;<br>
+<br>
   INTERCEPT_FUNCTION(malloc);<br>
   INTERCEPT_FUNCTION(free);<br>
   LSAN_MAYBE_INTERCEPT_CFREE;<br>
<br>
Modified: compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common.h?rev=314041&r1=314040&<wbr>r2=314041&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common.h (original)<br>
+++ compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common.h Fri Sep 22 15:57:48 2017<br>
@@ -318,15 +318,24 @@ void SetSoftRssLimitExceededCallbac<wbr>k(voi<br>
 typedef void (*SignalHandlerType)(int, void *, void *);<br>
 HandleSignalMode GetHandleSignalMode(int signum);<br>
 void InstallDeadlySignalHandlers(<wbr>SignalHandlerType handler);<br>
+<br>
 // Signal reporting.<br>
-void StartReportDeadlySignal();<br>
 // Each sanitizer uses slightly different implementation of stack unwinding.<br>
 typedef void (*<wbr>UnwindSignalStackCallbackType)<wbr>(const SignalContext &sig,<br>
                                               const void *callback_context,<br>
                                               BufferedStackTrace *stack);<br>
+// Print deadly signal report and die.<br>
+void HandleDeadlySignal(void *siginfo, void *context, u32 tid,<br>
+                        UnwindSignalStackCallbackType unwind,<br>
+                        const void *unwind_context);<br>
+<br>
+// Part of HandleDeadlySignal, exposed for asan.<br>
+void StartReportDeadlySignal();<br>
+// Part of HandleDeadlySignal, exposed for asan.<br>
 void ReportDeadlySignal(const SignalContext &sig, u32 tid,<br>
                         UnwindSignalStackCallbackType unwind,<br>
                         const void *unwind_context);<br>
+<br>
 // Alternative signal stack (POSIX-only).<br>
 void SetAlternateSignalStack();<br>
 void UnsetAlternateSignalStack();<br>
<br>
Modified: compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common_libcdep.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common_libcdep.cc?rev=314041&<wbr>r1=314040&r2=314041&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common_libcdep.cc (original)<br>
+++ compiler-rt/trunk/lib/<wbr>sanitizer_common/sanitizer_<wbr>common_libcdep.cc Fri Sep 22 15:57:48 2017<br>
@@ -254,6 +254,18 @@ void ReportDeadlySignal(const SignalCont<br>
   else<br>
     ReportDeadlySignalImpl(sig, tid, unwind, unwind_context);<br>
 }<br>
+<br>
+void HandleDeadlySignal(void *siginfo, void *context, u32 tid,<br>
+                        UnwindSignalStackCallbackType unwind,<br>
+                        const void *unwind_context) {<br>
+  StartReportDeadlySignal();<br>
+  ScopedErrorReportLock rl;<br>
+  SignalContext sig(siginfo, context);<br>
+  ReportDeadlySignal(sig, tid, unwind, unwind_context);<br>
+  Report("ABORTING\n");<br>
+  Die();<br>
+}<br>
+<br>
 #endif  // !SANITIZER_FUCHSIA && !SANITIZER_GO<br>
<br>
 void WriteToSyslog(const char *msg) {<br>
<br>
Modified: compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/allow_user_segv.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/sanitizer_common/<wbr>TestCases/Linux/allow_user_<wbr>segv.cc?rev=314041&r1=314040&<wbr>r2=314041&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/allow_user_segv.cc (original)<br>
+++ compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/allow_user_segv.cc Fri Sep 22 15:57:48 2017<br>
@@ -18,7 +18,6 @@<br>
 // clang-format on<br>
<br>
 // Remove when fixed: <a href="https://github.com/google/sanitizers/issues/637" rel="noreferrer" target="_blank">https://github.com/google/<wbr>sanitizers/issues/637</a><br>
-// XFAIL: lsan<br>
 // XFAIL: msan<br>
 // XFAIL: tsan<br>
 // XFAIL: ubsan<br>
<br>
Modified: compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/assert.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/sanitizer_common/<wbr>TestCases/Linux/assert.cc?rev=<wbr>314041&r1=314040&r2=314041&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/assert.cc (original)<br>
+++ compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/assert.cc Fri Sep 22 15:57:48 2017<br>
@@ -7,11 +7,11 @@<br>
 // RUN: %env_tool_opts=handle_abort=1 not         %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s<br>
 // clang-format on<br>
<br>
-// FIXME: implement in other sanitizers, not just asan.<br>
+// FIXME: implement in other sanitizers.<br>
 // XFAIL: msan<br>
-// XFAIL: lsan<br>
 // XFAIL: tsan<br>
 // XFAIL: ubsan<br>
+<br>
 #include <assert.h><br>
 #include <stdio.h><br>
 #include <sanitizer/asan_interface.h><br>
<br>
Modified: compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/ill.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/sanitizer_common/<wbr>TestCases/Linux/ill.cc?rev=<wbr>314041&r1=314040&r2=314041&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/ill.cc (original)<br>
+++ compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Linux/ill.cc Fri Sep 22 15:57:48 2017<br>
@@ -7,9 +7,8 @@<br>
 // RUN: %env_tool_opts=handle_sigill=1 not         %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s<br>
 // clang-format on<br>
<br>
-// FIXME: implement in other sanitizers, not just asan.<br>
+// FIXME: implement in other sanitizers.<br>
 // XFAIL: msan<br>
-// XFAIL: lsan<br>
 // XFAIL: tsan<br>
 // XFAIL: ubsan<br>
 //<br>
<br>
Modified: compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/dedup_token_length_test.<wbr>cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/sanitizer_common/<wbr>TestCases/Posix/dedup_token_<wbr>length_test.cc?rev=314041&r1=<wbr>314040&r2=314041&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/dedup_token_length_test.<wbr>cc (original)<br>
+++ compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/dedup_token_length_test.<wbr>cc Fri Sep 22 15:57:48 2017<br>
@@ -9,7 +9,6 @@<br>
 // REQUIRES: stable-runtime<br>
 // FIXME: implement SEGV handler in other sanitizers, not just asan.<br>
 // XFAIL: msan<br>
-// XFAIL: lsan<br>
 // XFAIL: tsan<br>
 // XFAIL: ubsan<br>
<br>
<br>
Modified: compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/dump_instruction_bytes.<wbr>cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/sanitizer_common/<wbr>TestCases/Posix/dump_<wbr>instruction_bytes.cc?rev=<wbr>314041&r1=314040&r2=314041&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/dump_instruction_bytes.<wbr>cc (original)<br>
+++ compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/dump_instruction_bytes.<wbr>cc Fri Sep 22 15:57:48 2017<br>
@@ -8,7 +8,10 @@<br>
 // clang-format on<br>
<br>
 // REQUIRES: x86-target-arch<br>
-// XFAIL: lsan, msan, tsan, ubsan<br>
+// FIXME: implement in other sanitizers.<br>
+// XFAIL: msan<br>
+// XFAIL: tsan<br>
+// XFAIL: ubsan<br>
<br>
 int main() {<br>
 #if defined(__x86_64__)<br>
<br>
Modified: compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/fpe.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/sanitizer_common/<wbr>TestCases/Posix/fpe.cc?rev=<wbr>314041&r1=314040&r2=314041&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/fpe.cc (original)<br>
+++ compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/fpe.cc Fri Sep 22 15:57:48 2017<br>
@@ -5,7 +5,6 @@<br>
 // RUN: %env_tool_opts=handle_sigfpe=1 not         %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s<br>
 // FIXME: implement in other sanitizers, not just asan.<br>
 // XFAIL: msan<br>
-// XFAIL: lsan<br>
 // XFAIL: tsan<br>
 // XFAIL: ubsan<br>
 //<br>
<br>
Modified: compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/sanitizer_set_report_fd_<wbr>test.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc?rev=314041&r1=314040&r2=314041&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/sanitizer_common/<wbr>TestCases/Posix/sanitizer_set_<wbr>report_fd_test.cc?rev=314041&<wbr>r1=314040&r2=314041&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/sanitizer_set_report_fd_<wbr>test.cc (original)<br>
+++ compiler-rt/trunk/test/<wbr>sanitizer_common/TestCases/<wbr>Posix/sanitizer_set_report_fd_<wbr>test.cc Fri Sep 22 15:57:48 2017<br>
@@ -8,7 +8,6 @@<br>
 // XFAIL: android && i386-target-arch && asan<br>
 // FIXME: implement SEGV handler in other sanitizers, not just asan.<br>
 // XFAIL: msan<br>
-// XFAIL: lsan<br>
 // XFAIL: tsan<br>
 // XFAIL: ubsan<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>