[compiler-rt] r263939 - [tsan] Add some NULL pointer checks into the debugging API

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 05:12:44 PDT 2016


Author: kuba.brecka
Date: Mon Mar 21 07:12:44 2016
New Revision: 263939

URL: http://llvm.org/viewvc/llvm-project?rev=263939&view=rev
Log:
[tsan] Add some NULL pointer checks into the debugging API

`__tsan_get_report_thread` and others can crash if a stack trace is missing, let's add the missing checks.

Differential Revision: http://reviews.llvm.org/D18306


Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_debugging.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_debugging.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_debugging.cc?rev=263939&r1=263938&r2=263939&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_debugging.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_debugging.cc Mon Mar 21 07:12:44 2016
@@ -86,8 +86,8 @@ int __tsan_get_report_stack(void *report
   const ReportDesc *rep = (ReportDesc *)report;
   CHECK_LT(idx, rep->stacks.Size());
   ReportStack *stack = rep->stacks[idx];
-  CopyTrace(stack->frames, trace, trace_size);
-  return 1;
+  if (stack) CopyTrace(stack->frames, trace, trace_size);
+  return stack ? 1 : 0;
 }
 
 SANITIZER_INTERFACE_ATTRIBUTE
@@ -102,7 +102,7 @@ int __tsan_get_report_mop(void *report,
   *size = mop->size;
   *write = mop->write ? 1 : 0;
   *atomic = mop->atomic ? 1 : 0;
-  CopyTrace(mop->stack->frames, trace, trace_size);
+  if (mop->stack) CopyTrace(mop->stack->frames, trace, trace_size);
   return 1;
 }
 
@@ -134,7 +134,7 @@ int __tsan_get_report_mutex(void *report
   *mutex_id = mutex->id;
   *addr = (void *)mutex->addr;
   *destroyed = mutex->destroyed;
-  CopyTrace(mutex->stack->frames, trace, trace_size);
+  if (mutex->stack) CopyTrace(mutex->stack->frames, trace, trace_size);
   return 1;
 }
 
@@ -150,7 +150,7 @@ int __tsan_get_report_thread(void *repor
   *running = thread->running;
   *name = thread->name;
   *parent_tid = thread->parent_tid;
-  CopyTrace(thread->stack->frames, trace, trace_size);
+  if (thread->stack) CopyTrace(thread->stack->frames, trace, trace_size);
   return 1;
 }
 




More information about the llvm-commits mailing list