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

Unified Diff: base/debug/stack_trace_win.cc

Issue 1387913002: Copy the register context before calling StackWalk64 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 | « base/debug/stack_trace.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace_win.cc
diff --git a/base/debug/stack_trace_win.cc b/base/debug/stack_trace_win.cc
index d5be5efb3558a1fcedba409e72b6f23efde840b2..2679077b76e40bbd413f89560328beb10c444334 100644
--- a/base/debug/stack_trace_win.cc
+++ b/base/debug/stack_trace_win.cc
@@ -222,11 +222,19 @@ StackTrace::StackTrace(EXCEPTION_POINTERS* exception_pointers) {
InitTrace(exception_pointers->ContextRecord);
}
-StackTrace::StackTrace(CONTEXT* context) {
+StackTrace::StackTrace(const CONTEXT* context) {
InitTrace(context);
}
-void StackTrace::InitTrace(CONTEXT* context_record) {
+void StackTrace::InitTrace(const CONTEXT* context_record) {
+ // StackWalk64 modifies the register context in place, so we have to copy it
+ // so that downstream exception handlers get the right context. The incoming
+ // context may have had more register state (YMM, etc) than we need to unwind
+ // the stack. Typically StackWalk64 only needs integer and control registers.
+ CONTEXT context_copy;
+ memcpy(&context_copy, context_record, sizeof(context_copy));
+ context_copy.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL;
+
// When walking an exception stack, we need to use StackWalk64().
count_ = 0;
// Initialize stack walking.
@@ -250,7 +258,7 @@ void StackTrace::InitTrace(CONTEXT* context_record) {
GetCurrentProcess(),
GetCurrentThread(),
&stack_frame,
- context_record,
+ &context_copy,
NULL,
&SymFunctionTableAccess64,
&SymGetModuleBase64,
« no previous file with comments | « base/debug/stack_trace.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698