[compiler-rt] r354717 - [NFC][Sanitizer] Add argument checks to BufferedStackTrace::Unwind* functions
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 22 18:36:24 PST 2019
Author: yln
Date: Fri Feb 22 18:36:23 2019
New Revision: 354717
URL: http://llvm.org/viewvc/llvm-project?rev=354717&view=rev
Log:
[NFC][Sanitizer] Add argument checks to BufferedStackTrace::Unwind* functions
Reviewers: vitalybuka
Differential Revision: https://reviews.llvm.org/D58555
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace_sparc.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_markup.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_win.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc?rev=354717&r1=354716&r2=354717&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc Fri Feb 22 18:36:23 2019
@@ -70,8 +70,10 @@ static inline uhwptr *GetCanonicFrame(up
void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top,
uptr stack_bottom, u32 max_depth) {
- const uptr kPageSize = GetPageSizeCached();
+ CHECK_NE(stack_bottom, 0);
+ CHECK_GT(stack_top, stack_bottom);
CHECK_GE(max_depth, 2);
+ const uptr kPageSize = GetPageSizeCached();
trace_buffer[0] = pc;
size = 1;
if (stack_top < 4096) return; // Sanity check for stack top.
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h?rev=354717&r1=354716&r2=354717&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h Fri Feb 22 18:36:23 2019
@@ -56,9 +56,11 @@ struct StackTrace {
void Print() const;
static bool WillUseFastUnwind(bool request_fast_unwind) {
+ static_assert(SANITIZER_CAN_FAST_UNWIND || SANITIZER_CAN_SLOW_UNWIND,
+ "Neither fast nor slow unwinder is supported");
if (!SANITIZER_CAN_FAST_UNWIND)
return false;
- else if (!SANITIZER_CAN_SLOW_UNWIND)
+ if (!SANITIZER_CAN_SLOW_UNWIND)
return true;
return request_fast_unwind;
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace_sparc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace_sparc.cc?rev=354717&r1=354716&r2=354717&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace_sparc.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace_sparc.cc Fri Feb 22 18:36:23 2019
@@ -23,8 +23,10 @@ namespace __sanitizer {
void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top,
uptr stack_bottom, u32 max_depth) {
- const uptr kPageSize = GetPageSizeCached();
+ CHECK_NE(stack_bottom, 0);
+ CHECK_GT(stack_top, stack_bottom);
CHECK_GE(max_depth, 2);
+ const uptr kPageSize = GetPageSizeCached();
trace_buffer[0] = pc;
size = 1;
if (stack_top < 4096) return; // Sanity check for stack top.
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_markup.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_markup.cc?rev=354717&r1=354716&r2=354717&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_markup.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_markup.cc Fri Feb 22 18:36:23 2019
@@ -132,9 +132,9 @@ void BufferedStackTrace::UnwindSlow(uptr
trace_buffer[0] = pc;
}
-void BufferedStackTrace::UnwindSlow(uptr pc, void *context,
- u32 max_depth) {
- CHECK_NE(context, nullptr);
+void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {
+ CHECK(context);
+ CHECK_GE(max_depth, 2);
UNREACHABLE("signal context doesn't exist");
}
#endif // SANITIZER_CAN_SLOW_UNWIND
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc?rev=354717&r1=354716&r2=354717&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc Fri Feb 22 18:36:23 2019
@@ -138,8 +138,8 @@ void BufferedStackTrace::UnwindSlow(uptr
trace_buffer[0] = pc;
}
-void BufferedStackTrace::UnwindSlow(uptr pc, void *context,
- u32 max_depth) {
+void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {
+ CHECK(context);
CHECK_GE(max_depth, 2);
if (!unwind_backtrace_signal_arch) {
UnwindSlow(pc, max_depth);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_win.cc?rev=354717&r1=354716&r2=354717&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_win.cc Fri Feb 22 18:36:23 2019
@@ -39,8 +39,9 @@ void BufferedStackTrace::UnwindSlow(uptr
PopStackFrames(pc_location);
}
-void BufferedStackTrace::UnwindSlow(uptr pc, void *context,
- u32 max_depth) {
+void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {
+ CHECK(context);
+ CHECK_GE(max_depth, 2);
CONTEXT ctx = *(CONTEXT *)context;
STACKFRAME64 stack_frame;
memset(&stack_frame, 0, sizeof(stack_frame));
More information about the llvm-commits
mailing list