Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1494)

Unified Diff: base/debug/stack_trace.h

Issue 1975393002: Check stack pointer to be inside stack when unwinding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement mincore() approach Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/debug/stack_trace.cc » ('j') | base/debug/stack_trace.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace.h
diff --git a/base/debug/stack_trace.h b/base/debug/stack_trace.h
index 23e7b5164b63472409a92e992c5c1095dfa48d26..749b5ee4785cccb0fc09b89f1cfca8bf16b7c55f 100644
--- a/base/debug/stack_trace.h
+++ b/base/debug/stack_trace.h
@@ -102,6 +102,14 @@ class BASE_EXPORT StackTrace {
};
#if HAVE_TRACE_STACK_FRAME_POINTERS
+
+// Used by TraceStackFramePointers() to store info about the stack.
+struct BASE_EXPORT PerThreadStackInfo {
Primiano Tucci (use gerrit) 2016/05/31 16:13:07 maybe s/PerThreadStackInfo/ThreadStackLimits/
Dmitry Skiba 2016/05/31 21:52:18 Acknowledged.
+ PerThreadStackInfo();
+ uintptr_t start_address;
+ bool start_address_final;
+};
+
// Traces the stack by using frame pointers. This function is faster but less
// reliable than StackTrace. It should work for debug and profiling builds,
// but not for release builds (although there are some exceptions).
@@ -110,9 +118,21 @@ class BASE_EXPORT StackTrace {
// after skipping |skip_initial| frames. Note that the function itself is not
// added to the trace so |skip_initial| should be 0 in most cases.
// Returns number of frames written.
-BASE_EXPORT size_t TraceStackFramePointers(const void** out_trace,
- size_t max_depth,
- size_t skip_initial);
+//
+// Note on |stack_info|. By default the function relies on heuristics to check
Primiano Tucci (use gerrit) 2016/05/31 16:13:07 IMHO this comment is a bit too apologetic. I'd jus
Dmitry Skiba 2016/05/31 21:52:18 Hmm, I don't see it that way. I think it explains
+// whether a stack pointer is within the stack before dereferencing it. That
+// works, but is not very reliable. Proper way to check that is to ask the OS
+// for the stack info, but that is costly thing to do on each call.
+// This is what |stack_info| is for - it provides a place where function
+// caches info about the stack. Put it in your per-thread data structure, pass
+// into the function, and voila - stack pointers are properly checked without
+// any runtime overhead.
+BASE_EXPORT size_t TraceStackFramePointers(
+ const void** out_trace,
+ size_t max_depth,
+ size_t skip_initial,
+ PerThreadStackInfo* stack_info = nullptr);
+
#endif // HAVE_TRACE_STACK_FRAME_POINTERS
namespace internal {
« no previous file with comments | « no previous file | base/debug/stack_trace.cc » ('j') | base/debug/stack_trace.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698