<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 - vfork broken with -fno-builtin"
href="https://bugs.llvm.org/show_bug.cgi?id=41822">41822</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>vfork broken with -fno-builtin
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eugeni.stepanov@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>-fno-builtin removes returns_twice attribute from vfork.
Unlike most other attributes, this one is required for correctness.
Missing returns_twice allows the optimizer to use tail calls in the caller of
vfork.
Child process can not use a tail call, because that is effectively a return
from the caller of vfork, and it corrupts the stack of the parent process.
$ cat 1.cc
#include <unistd.h>
__attribute__((optnone, noinline)) static void child() {
volatile bool z = false;
if (!z) _exit(0);
}
void zzztest() {
if (!vfork()) {
child();
}
}
$ bin/clang++ -target armv7-linux 1.cc -O2 -c -fno-builtin && objdump -drl
1.o
_Z7zzztestv():
0: e92d4800 push {fp, lr}
4: e1a0b00d mov fp, sp
8: ebfffffe bl 0 <vfork>
8: R_ARM_CALL vfork
c: e3500000 cmp r0, #0
10: 18bd8800 popne {fp, pc}
14: e8bd4800 pop {fp, lr}
18: eaffffff b 1c <_ZL5childv></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>