[llvm-bugs] [Bug 25514] New: [WinEH] x64 UnwindHelp offset is wrong for realigned stack frames

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 12 16:35:19 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25514

            Bug ID: 25514
           Summary: [WinEH] x64 UnwindHelp offset is wrong for realigned
                    stack frames
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: david.majnemer at gmail.com, JCTremoulet at gmail.com,
                    llvm-bugs at lists.llvm.org
    Classification: Unclassified

Consider:

#include <stdio.h>
struct HasDtor {
  ~HasDtor() { puts("~HasDtor"); }
};
void throwit() { throw 2; }
void *p;
void realigned() {
  __declspec(align(64)) HasDtor o;
  p = &o;
  throwit();
}
int main() {
  try {
    realigned();
  } catch (...) {
    puts("caught");
  }
}

We generate this cppxdata:

$cppxdata$main:
        .long   429065506
        .long   2
        .long   ($stateUnwindMap$main)@IMGREL
        .long   1
        .long   ($tryMap$main)@IMGREL
        .long   3
        .long   ($ip2state$main)@IMGREL
        .long   40
        .long   0
        .long   1

It says that UnwindHelp is at offset 40 of RSP-after-prologue. However, we
allocate UnwindHelp using a regular stack object (not fixed), so it is actually
in the local variable area, which is realigned. Our initialization of this slot
with -2 shows that:

        subq    $104, %rsp
...
        .seh_endprologue
        andq    $-64, %rsp
        movq    %rsp, %rbx
        movq    %rbp, 48(%rbx)
        movq    $-2, 56(%rbx)

RBX + 56 is not the same memory as RSP-after-prologue + 40.

Found in this test:
https://github.com/Microsoft/compiler-tests/blob/master/eh/ehframes.cpp

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151113/6ac10f23/attachment.html>


More information about the llvm-bugs mailing list