gccgo and syscall.SysProcAttr.Cloneflags

48 views
Skip to first unread message

Michael Hudson-Doyle

unread,
Sep 1, 2014, 7:18:58 AM9/1/14
to gofrontend-dev
Hi,

It's late for me and I don't have a proper test case but it seems to me
that while gccgo's syscall lets you set Cloneflags on its SysProcAttr,
but doesn't actually *do* anything with the flags. Am I missing
something?

(This makes docker's libcontainer very exciting to use: it tries to run
a child process in a different mount namespace which calls pivot_root,
but it's actually in the root mount namespace... so suddenly your rootfs
looks completely and unexpectedly different)

Cheers,
mwh

Ian Lance Taylor

unread,
Sep 5, 2014, 11:25:17 AM9/5/14
to Michael Hudson-Doyle, gofrontend-dev, gcc-patches
On Mon, Sep 1, 2014 at 4:18 AM, Michael Hudson-Doyle
<michael...@linaro.org> wrote:
>
> It's late for me and I don't have a proper test case but it seems to me
> that while gccgo's syscall lets you set Cloneflags on its SysProcAttr,
> but doesn't actually *do* anything with the flags. Am I missing
> something?

You aren't missing anything. I made an error in an libgo merge last
year. This patch fixes the problem. Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.9
branch.

Ian

diff -r da369647d0ec libgo/go/syscall/exec_linux.go
--- a/libgo/go/syscall/exec_linux.go Fri Sep 05 07:42:57 2014 -0700
+++ b/libgo/go/syscall/exec_linux.go Fri Sep 05 08:05:22 2014 -0700
@@ -43,7 +43,7 @@
// Declare all variables at top in case any
// declarations require heap allocation (e.g., err1).
var (
- r1 Pid_t
+ r1 uintptr
err1 Errno
nextfd int
i int
@@ -65,7 +65,7 @@
// About to call fork.
// No more allocation or calls of non-assembly functions.
runtime_BeforeFork()
- r1, err1 = raw_fork()
+ r1, _, err1 = RawSyscall6(SYS_CLONE,
uintptr(SIGCHLD)|sys.Cloneflags, 0, 0, 0, 0, 0)
if err1 != 0 {
runtime_AfterFork()
return 0, err1

Michael Hudson-Doyle

unread,
Sep 6, 2014, 10:01:20 PM9/6/14
to Ian Lance Taylor, gofrontend-dev, gcc-patches
Ian Lance Taylor <ia...@golang.org> writes:

> On Mon, Sep 1, 2014 at 4:18 AM, Michael Hudson-Doyle
> <michael...@linaro.org> wrote:
>>
>> It's late for me and I don't have a proper test case but it seems to me
>> that while gccgo's syscall lets you set Cloneflags on its SysProcAttr,
>> but doesn't actually *do* anything with the flags. Am I missing
>> something?
>
> You aren't missing anything. I made an error in an libgo merge last
> year. This patch fixes the problem.

Hi, I can confirm that docker's libcontainer works much better with this
patch! Thanks for the quick fix.

Cheers,
mwh
Reply all
Reply to author
Forward
0 new messages