Skip to content

Commit ebae562

Browse files
committed
[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
1 parent 5b9d969 commit ebae562

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

libunwind/src/UnwindCursor.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ UnwindCursor<A, R>::UnwindCursor(unw_context_t *context, A &as)
579579
_dispContext.HistoryTable = &_histTable;
580580
// Initialize MS context from ours.
581581
R r(context);
582+
RtlCaptureContext(&_msContext);
582583
_msContext.ContextFlags = CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_FLOATING_POINT;
583584
#if defined(_LIBUNWIND_TARGET_X86_64)
584585
_msContext.Rax = r.getRegister(UNW_X86_64_RAX);

0 commit comments

Comments
 (0)