Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fork/exec broken pipe #31157

Closed
cxpbbs opened this issue Mar 30, 2019 · 2 comments
Closed

fork/exec broken pipe #31157

cxpbbs opened this issue Mar 30, 2019 · 2 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@cxpbbs
Copy link

cxpbbs commented Mar 30, 2019

What version of Go are you using (go version)?

$ go version
1.7.3

Does this issue reproduce with the latest release?

Can't reproduce

What operating system and processor architecture are you using (go env)?

Linux 3.10.0-327.36.58.4.x86_64 #1 SMP x86_64 GNU/Linux

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/gopath"
GORACE=""
GOROOT="/usr/lib/golang"
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build779701576=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

Loop creation process:
for i := 0; i < 1000; i++ {
cmd[i] = exec.Command("sleep", "1")
err := cmd[i].Start()
if err != nil {
fmt.Println("start process error:", err)
os.Exit(2)
}
}
for i := 0; i < 1000; i++ {
err := cmd[i].Wait()
if err != nil {
fmt.Println("wait error:", err)
os.Exit(3)
}
}

What did you expect to see?

Successfully created 1000 processes

What did you see instead?

errmsg:
fork/exec:broken pipe:""

View the source code, found that the error code may be as follows:

  1. in func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err error):
    from: https://github.com/golang/go/blob/release-branch.go1.7/src/os/exec_posix.go +47
    pid, h, e := syscall.StartProcess(name, argv, sysattr)
    if e != nil {
    return nil, &PathError{"fork/exec", name, e}
    }

2)func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) maybe return epipe
from:https://github.com/golang/go/blob/release-branch.go1.7/src/syscall/exec_unix.go + 209

    Close(p[1])
n, err = readlen(p[0], (*byte)(unsafe.Pointer(&err1)), int(unsafe.Sizeof(err1)))
Close(p[0])
if err != nil || n != 0 {
	if n == int(unsafe.Sizeof(err1)) {
		err = Errno(err1)
	}
	if err == nil {
		err = EPIPE   //The error can happen here
	}

	// Child failed; wait for it to exit, to make sure
	// the zombies don't accumulate.
	_, err1 := Wait4(pid, &wstatus, 0, nil)
	for err1 == EINTR {
		_, err1 = Wait4(pid, &wstatus, 0, nil)
	}
	return 0, err
}

// Read got EOF, so pipe closed on exec, so exec succeeded.
return pid, nil

Now I can't reproduce the error. Can you tell me what scenes might return this error when reading pipe?

@ianlancetaylor
Copy link
Contributor

Go 1.7 is no longer supported.

I was unable to reproduce the problem with either Go 1.7 or tip.

@davecheney davecheney added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 1, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Apr 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants