[PATCH] D147636: [libunwind] [SEH] Initialize _msContext with RtlCaptureContext

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 13:45:01 PDT 2023


mstorsjo added a comment.

In D147636#4249742 <https://reviews.llvm.org/D147636#4249742>, @cdavis5x wrote:

> I had hoped to avoid that duplicated work here. Clearly there was something I missed...

Yep - I didn't quite pinpoint what goes wrong and where, but it's reproducible both on Wine and on native Windows. A (untested) mini repro of the issue might look something like this:

  CONTEXT ctx;
  RtlCaptureContext(&ctx);
  static int Restored = 0;
  if (!Restored) {
    Restored = 1;
    ctx.ContextFlags &= CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_FLOATING_POINT;
    ctx.SegCs = 0;
    RtlRestoreContext(&ctx);
  }

One could think it's ok to clobber `SegCs` since `ContextFlags` doesn't have `CONTEXT_SEGMENTS` set - but it looks like it does matter nevertheless.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147636/new/

https://reviews.llvm.org/D147636



More information about the llvm-commits mailing list