Repository: go
Issue: gollvm: runc runtime error,  broken pipe
Labels: NeedsInvestigation

<!-- Please answer these questions before submitting your issue. Thanks! -->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.13 gollvm LLVM 10.0.0svn linux/amd64
</pre>

### Does this issue reproduce with the latest release?
Yes

### What operating system and processor architecture are you using (`go env`)?

<pre>
Ubuntu 18.04.3 LTS, x86_64
</pre>

### What did you do?

[helloworld_rootfs.tar.gz](https://github.com/golang/go/files/3906297/helloworld_rootfs.tar.gz)
<pre>
$ cd <workdir>
$ git clone https://github.com/opencontainers/runc.git
$ cd runc
$ mkdir -p .gopath/src/github.com/opencontainers/
$ ln -sf `pwd` `pwd`/.gopath/src/github.com/opencontainers/runc
$ export GOPATH=`pwd`/.gopath
$ cd .gopath/src/github.com/opencontainers/runc/
$ go build -tags "seccomp" -o runc .

$ cd <workdir>
$ mkdir mycontainer
$ cp helloworld_rootfs.tar.gz mycontainer
$ cd mycontainer
$ tar -xf helloworld_rootfs.tar.gz

$ ../runc/runc spec --rootless
$ sed -i 's;"sh";"/hello";' config.json
$ ../runc/runc run mycontainer
</pre>

### What did you expect to see?     
<pre>                                                                      
Hello from Docker!                                                                                                                            
This message shows that your installation appears to be working correctly.
...
</pre>
### What did you see instead?
<pre>
$ ../runc/runc run mycontainer
WARN[0000] exit status 127                              
ERRO[0000] container_linux.go:346: starting container process caused "process_linux.go:315: copying bootstrap data to pipe caused \"write init-p: broken pipe\"" 
container_linux.go:346: starting container process caused "process_linux.go:315: copying bootstrap data to pipe caused \"write init-p: broken pipe\""

$ gdb --args ../runc/runc run mycontainer
...
Thread 6 "runc" received signal SIGPIPE, Broken pipe.
[Switching to Thread 0x7fffe97f8700 (LWP 17662)]
0x00007ffff59ed187 in __GI___libc_write (fd=7, buf=0xc000236100, nbytes=64) at ../sysdeps/unix/sysv/linux/write.c:27
27      ../sysdeps/unix/sysv/linux/write.c: No such file or directory.
(gdb) bt
#0  0x00007ffff59ed187 in __GI___libc_write (fd=7, buf=0xc000236100, nbytes=64) at ../sysdeps/unix/sysv/linux/write.c:27
#1  0x00007ffff717a768 in syscall.write (fd=7, p=...) at build.rel/tools/gollvm/libgo/libcalls.go:2654
#2  syscall.Write (fd=7, p=...) at llvm/tools/gollvm/gofrontend/libgo/go/syscall/syscall_unix.go:168
#3  0x00007ffff6f6eb23 in internal..z2fpoll.FD.Write (fd=0xc0000ec1e0, p=...)
    at llvm/tools/gollvm/gofrontend/libgo/go/internal/poll/fd_unix.go:268
#4  0x00007ffff70a1a62 in os.File.write (f=0xc0000f6040, b=...)
    at llvm/tools/gollvm/gofrontend/libgo/go/os/file_unix.go:290
#5  0x00007ffff70a0f4e in os.File.Write (f=0xc0000f6040, b=...)
    at llvm/tools/gollvm/gofrontend/libgo/go/os/file.go:153
#6  0x00007ffff6d10674 in bytes.Reader.WriteTo (r=0xc0000f2270, w=...)
    at llvm/tools/gollvm/gofrontend/libgo/go/bytes/reader.go:144
#7  0x00007ffff6f8ef33 in io.copyBuffer (dst=..., src=..., buf=...)
    at llvm/tools/gollvm/gofrontend/libgo/go/io/io.go:384
#8  0x00007ffff6f8ecfd in io.Copy (dst=..., src=...) at llvm/tools/gollvm/gofrontend/libgo/go/io/io.go:364
#9  0x0000000000621d87 in github.x2ecom..z2fopencontainers..z2frunc..z2flibcontainer.initProcess.start (p=0xffffffffffffffe0)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/libcontainer/process_linux.go:314
#10 0x0000000000624f33 in github.x2ecom..z2fopencontainers..z2frunc..z2flibcontainer.linuxContainer.start (c=0xc0000bc2d0,
    process=0xc0000a2780)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/libcontainer/container_linux.go:341
#11 0x00000000006193a3 in github.x2ecom..z2fopencontainers..z2frunc..z2flibcontainer.linuxContainer.Start (c=0xc0000bc2d0,
    process=0xc0000a2780)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/libcontainer/container_linux.go:241
#12 0x0000000000618e2a in github.x2ecom..z2fopencontainers..z2frunc..z2flibcontainer.linuxContainer.Run (c=0xc0000bc2d0,
    process=0xc0000a2780)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/libcontainer/container_linux.go:251
#13 0x0000000000608235 in main.runner.run (r=0xffffffffffffffe0, config=0xc00010c0e0)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/utils_linux.go:324
#14 0x0000000000603093 in main.startContainer (context=<optimized out>, spec=0xffffffffffffffe0, action=2 '\002', criuOpts=<optimized out>)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/utils_linux.go:452
#15 0x000000000060cf9f in main.func13 (context=0xc0000ac840)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/run.go:76
#16 0x000000000066eeec in github.x2ecom..z2fopencontainers..z2frunc..z2fvendor..z2fgithub.x2ecom..z2furfave..z2fcli.HandleAction (
    action=..., context=0xc0000ac840)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/vendor/github.com/urfave/cli/app.go:495
#17 0x0000000000669e6e in github.x2ecom..z2fopencontainers..z2frunc..z2fvendor..z2fgithub.x2ecom..z2furfave..z2fcli.Command.Run (
    pointer=<optimized out>, ctx=0xc0000ac6e0)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/vendor/github.com/urfave/cli/command.go:210
#18 0x000000000066bc19 in github.x2ecom..z2fopencontainers..z2frunc..z2fvendor..z2fgithub.x2ecom..z2furfave..z2fcli.App.Run (
---Type <return> to continue, or q <return> to quit---
    a=<optimized out>, arguments=...)
    at github_issue/runc/.gopath/src/github.com/opencontainers/runc/vendor/github.com/urfave/cli/app.go:255
#19 0x000000000060b0f1 in main.main () at github_issue/runc/.gopath/src/github.com/opencontainers/runc/main.go:145
</pre>

### Comments
This is a runtime issue of runc built with gollvm. It doesn't reproduce for gccgo and golang 1.10.
I am sorry, I didn't know how to make a short example.

helloworld_rootfs.tar.gz  contains hello-world container example created using runc manpages:
[https://github.com/opencontainers/runc/blob/master/man/runc-spec.8.md](url)
<pre>
$ docker pull hello-world
$ docker export $(docker create hello-world) > hello-world.tar
$ mkdir rootfs
$ tar -C rootfs -xf hello-world.tar
</pre>