[PATCH] D73809: eSupport] Don't modify the current EH context during stack unwinding
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 14:44:48 PST 2020
rnk created this revision.
rnk added reviewers: stella.stamenova, aganea.
Herald added a subscriber: hiraditya.
Herald added a reviewer: jfb.
Herald added a project: LLVM.
Copy it instead. Otherwise, key registers (such as RBP) may get zeroed
out by the stack unwinder.
Fixes CrashRecoveryTest.DumpStackCleanup with MSVC in release builds.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73809
Files:
llvm/lib/Support/Windows/Signals.inc
Index: llvm/lib/Support/Windows/Signals.inc
===================================================================
--- llvm/lib/Support/Windows/Signals.inc
+++ llvm/lib/Support/Windows/Signals.inc
@@ -820,7 +820,13 @@
<< "\n";
}
- LocalPrintStackTrace(llvm::errs(), ep ? ep->ContextRecord : nullptr);
+ // Stack unwinding appears to modify the context. Copy it to preserve the
+ // caller's context.
+ CONTEXT ContextCopy;
+ if (ep)
+ memcpy(&ContextCopy, ep->ContextRecord, sizeof(ContextCopy));
+
+ LocalPrintStackTrace(llvm::errs(), ep ? &ContextCopy : nullptr);
return EXCEPTION_EXECUTE_HANDLER;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73809.241820.patch
Type: text/x-patch
Size: 639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200131/6a8d7dc8/attachment.bin>
More information about the llvm-commits
mailing list