<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [WinEH] x64 UnwindHelp offset is wrong for realigned stack frames"
href="https://llvm.org/bugs/show_bug.cgi?id=25514">25514</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[WinEH] x64 UnwindHelp offset is wrong for realigned stack frames
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rnk@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>david.majnemer@gmail.com, JCTremoulet@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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:
<a href="https://github.com/Microsoft/compiler-tests/blob/master/eh/ehframes.cpp">https://github.com/Microsoft/compiler-tests/blob/master/eh/ehframes.cpp</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>