diff options
author | Martin Storsjö <martin@martin.st> | 2023-04-04 20:28:49 +0000 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2023-04-13 12:03:35 +0300 |
commit | ebae5622d11655feaa74e64151067897153f9c71 (patch) | |
tree | 1a80c4c90587cf11eaa499df714e6f2ad4f6cd17 /libunwind | |
parent | 5b9d969e7c07d720080eac386467c1112c45a76f (diff) | |
download | llvm-ebae5622d11655feaa74e64151067897153f9c71.zip llvm-ebae5622d11655feaa74e64151067897153f9c71.tar.gz llvm-ebae5622d11655feaa74e64151067897153f9c71.tar.bz2 |
[libunwind] [SEH] Initialize _msContext with RtlCaptureContext
When we initialize the UnwindCursor (unw_cursor_t) based on
an existing Registers object (unw_context_t), we only initialize
a subset of the class.
Fill the struct properly for the current thread with RtlCaptureContext,
followed by overwriting of the subset of registers that we do have
available in the Registers class.
One might think that it's enough to initialize specifically the
registers that we signal availability for with ContextFlags,
however in practice, that's not enough.
This fixes crashes when restoring the context via RtlRestoreContext
(via UnwindCursor::jumpto), via __unw_resume.
Differential Revision: https://reviews.llvm.org/D147636
Diffstat (limited to 'libunwind')
-rw-r--r-- | libunwind/src/UnwindCursor.hpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 9ea0cf1..8b6451c 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -579,6 +579,7 @@ UnwindCursor<A, R>::UnwindCursor(unw_context_t *context, A &as) _dispContext.HistoryTable = &_histTable; // Initialize MS context from ours. R r(context); + RtlCaptureContext(&_msContext); _msContext.ContextFlags = CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_FLOATING_POINT; #if defined(_LIBUNWIND_TARGET_X86_64) _msContext.Rax = r.getRegister(UNW_X86_64_RAX); |