[PATCH] D14656: [sanitizer] Stop unwinding the stack when a close-to-zero PC is found
Kuba Brecka via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 03:01:00 PST 2015
kubabrecka updated this revision to Diff 40267.
kubabrecka added a comment.
Adding the check into slow unwinder as well.
http://reviews.llvm.org/D14656
Files:
lib/sanitizer_common/sanitizer_stacktrace.cc
lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
Index: lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
@@ -103,6 +103,8 @@
UnwindTraceArg *arg = (UnwindTraceArg*)param;
CHECK_LT(arg->stack->size, arg->max_depth);
uptr pc = Unwind_GetIP(ctx);
+ const uptr kPageSize = GetPageSizeCached();
+ if (pc < kPageSize) return UNWIND_STOP;
arg->stack->trace_buffer[arg->stack->size++] = pc;
if (arg->stack->size == arg->max_depth) return UNWIND_STOP;
return UNWIND_CONTINUE;
Index: lib/sanitizer_common/sanitizer_stacktrace.cc
===================================================================
--- lib/sanitizer_common/sanitizer_stacktrace.cc
+++ lib/sanitizer_common/sanitizer_stacktrace.cc
@@ -71,6 +71,7 @@
void BufferedStackTrace::FastUnwindStack(uptr pc, uptr bp, uptr stack_top,
uptr stack_bottom, u32 max_depth) {
+ const uptr kPageSize = GetPageSizeCached();
CHECK_GE(max_depth, 2);
trace_buffer[0] = pc;
size = 1;
@@ -95,6 +96,8 @@
#else
uhwptr pc1 = frame[1];
#endif
+ if (pc1 < kPageSize)
+ break;
if (pc1 != pc) {
trace_buffer[size++] = (uptr) pc1;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14656.40267.patch
Type: text/x-patch
Size: 1306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/535201cc/attachment.bin>
More information about the llvm-commits
mailing list