[PATCH] D58555: [NFC][Sanitizer] Add argument checks to BufferedStackTrace::Unwind* functions
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 22 18:35:55 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354717: [NFC][Sanitizer] Add argument checks to BufferedStackTrace::Unwind* functions (authored by yln, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D58555?vs=187985&id=188022#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58555/new/
https://reviews.llvm.org/D58555
Files:
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
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace_sparc.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace_sparc.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace_sparc.cc
@@ -23,8 +23,10 @@
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.
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
@@ -56,9 +56,11 @@
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;
}
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
@@ -70,8 +70,10 @@
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.
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_win.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_win.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_win.cc
@@ -39,8 +39,9 @@
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));
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
@@ -138,8 +138,8 @@
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);
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_markup.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_markup.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_markup.cc
@@ -132,9 +132,9 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58555.188022.patch
Type: text/x-patch
Size: 4232 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190223/7ca4f2f8/attachment.bin>
More information about the llvm-commits
mailing list