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

Unified Diff: base/debug/stack_trace_win.cc

Issue 267463003: Create copy of context record before passing it to StackWalk64 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 eb35b6ab91b642d4b5adfd47435bc5ed64f1a394..a3327afcea8d77787c5c94decb5480ecac4ff097 100644
--- a/base/debug/stack_trace_win.cc
+++ b/base/debug/stack_trace_win.cc
@@ -211,22 +211,25 @@ StackTrace::StackTrace() {
#pragma optimize("", on)
#endif
-StackTrace::StackTrace(EXCEPTION_POINTERS* exception_pointers) {
+StackTrace::StackTrace(const EXCEPTION_POINTERS* exception_pointers) {
// When walking an exception stack, we need to use StackWalk64().
count_ = 0;
+ // StackWalk64() may modify context record passed to it, so we will
+ // use a copy.
+ CONTEXT context_record = *exception_pointers->ContextRecord;
// Initialize stack walking.
STACKFRAME64 stack_frame;
memset(&stack_frame, 0, sizeof(stack_frame));
#if defined(_WIN64)
int machine_type = IMAGE_FILE_MACHINE_AMD64;
- stack_frame.AddrPC.Offset = exception_pointers->ContextRecord->Rip;
- stack_frame.AddrFrame.Offset = exception_pointers->ContextRecord->Rbp;
- stack_frame.AddrStack.Offset = exception_pointers->ContextRecord->Rsp;
+ stack_frame.AddrPC.Offset = context_record.Rip;
+ stack_frame.AddrFrame.Offset = context_record.Rbp;
+ stack_frame.AddrStack.Offset = context_record.Rsp;
#else
int machine_type = IMAGE_FILE_MACHINE_I386;
- stack_frame.AddrPC.Offset = exception_pointers->ContextRecord->Eip;
- stack_frame.AddrFrame.Offset = exception_pointers->ContextRecord->Ebp;
- stack_frame.AddrStack.Offset = exception_pointers->ContextRecord->Esp;
+ stack_frame.AddrPC.Offset = context_record.Eip;
+ stack_frame.AddrFrame.Offset = context_record.Ebp;
+ stack_frame.AddrStack.Offset = context_record.Esp;
#endif
stack_frame.AddrPC.Mode = AddrModeFlat;
stack_frame.AddrFrame.Mode = AddrModeFlat;
@@ -235,7 +238,7 @@ StackTrace::StackTrace(EXCEPTION_POINTERS* exception_pointers) {
GetCurrentProcess(),
GetCurrentThread(),
&stack_frame,
- exception_pointers->ContextRecord,
+ &context_record,
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