Bug ID: 41822
           Summary: vfork broken with -fno-builtin
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen

-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
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
#include <unistd.h>
__attribute__((optnone, noinline)) static void child() {
  volatile bool z = false;
  if (!z) _exit(0);

void zzztest() {
  if (!vfork()) {

$ bin/clang++  -target armv7-linux -O2 -c  -fno-builtin  && objdump -drl
   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>

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to