[PATCH] D148660: [libunwind] [SEH] Clear DISPATCHER_CONTEXT when initializing a cursor

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 14:00:45 PDT 2023


mstorsjo created this revision.
mstorsjo added a reviewer: cdavis5x.
Herald added a subscriber: kristof.beyls.
Herald added projects: libunwind, All.
Herald added a reviewer: libunwind.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We only initialize a few fields in DISPATCHER_CONTEXT - don't leave
the rest in an uninitialized state; make sure the whole struct is
in a deterministic state.

This makes nondeterministic failures deterministic, for some cases
relating to forced unwinding on aarch64/arm (which requires filling
in parsing of the xdata for finding the exception handler and LSDA).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148660

Files:
  libunwind/src/UnwindCursor.hpp


Index: libunwind/src/UnwindCursor.hpp
===================================================================
--- libunwind/src/UnwindCursor.hpp
+++ libunwind/src/UnwindCursor.hpp
@@ -575,6 +575,7 @@
                 "UnwindCursor<> requires more alignment than unw_cursor_t");
   memset(&_info, 0, sizeof(_info));
   memset(&_histTable, 0, sizeof(_histTable));
+  memset(&_dispContext, 0, sizeof(_dispContext));
   _dispContext.ContextRecord = &_msContext;
   _dispContext.HistoryTable = &_histTable;
   // Initialize MS context from ours.
@@ -677,6 +678,7 @@
                 "UnwindCursor<> does not fit in unw_cursor_t");
   memset(&_info, 0, sizeof(_info));
   memset(&_histTable, 0, sizeof(_histTable));
+  memset(&_dispContext, 0, sizeof(_dispContext));
   _dispContext.ContextRecord = &_msContext;
   _dispContext.HistoryTable = &_histTable;
   _msContext = *context;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148660.514738.patch
Type: text/x-patch
Size: 872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230418/26d5f18e/attachment.bin>


More information about the llvm-commits mailing list