<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - invoked functions returning structs with -enable-emscripten-cxx-exceptions causes runtime crashes"
href="https://bugs.llvm.org/show_bug.cgi?id=33824">33824</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>invoked functions returning structs with -enable-emscripten-cxx-exceptions causes runtime crashes
</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>Linux
</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: WebAssembly
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tlively@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18808" name="attach_18808" title="a small failing example">attachment 18808</a> <a href="attachment.cgi?id=18808&action=edit" title="a small failing example">[details]</a></span>
a small failing example
When -enable-emscripten-cxx-exceptions is used, the
WebAssemblyLowerEmscriptenEHSjLj pass lowers invoke instructions to calls to
calls to @__invoke_SIG functions that take the originally invoked function as a
first argument and have the same return type. If that return type is a struct,
the initial lowering step creates an sret parameter in the first argument
position, bumping the function pointer to the second argument position, which
causes a crash when the sret pointer is used as a function pointer at run time.
To reproduce:
llc exceptions.ll -enable-emscripten-cxx-exceptions -debug
Observe that
%ign = invoke { i32, i8* } @bar(i32 3)
to label %invoke.cont unwind label %lpad
is lowered to
...
%ign = call { i32, i8* } @"__invoke_{i32.i8*}_i32"({ i32, i8* } (i32)*
@bar, i32 3)
...
and later lowered to
...
CALL_VOID <ga:@"__invoke_{i32.i8*}_i32">, <fi#0>, %vreg2<kill>,
%vreg1<kill>, %ARGUMENTS<imp-def,dead>, %SP32<imp-use>, %SP64<imp-use>;
I32:%vreg2,%vreg1
...
which has the sret pointer, not the function pointer, as the first argument.</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>