Skip to content

os/exec: cmd.CombinedOutput seems stuck on an io.Copy under s390x #33704

@q2683252

Description

@q2683252

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

$ go version
go version go1.12.7 linux/s390x

Does this issue reproduce with the latest release?

Yes

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

go env Output

$ go env

P008-PG-S102A:~ # go env
GOARCH="s390x"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="s390x"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_s390x"
GCCGO="gccgo"
CC="s390x-linux-gnu-gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -march=z196 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build024277193=/tmp/go-build -gno-record-gcc-switches"

What did you do?

What did you expect to see?

I use go to protect a service which restarts the process when it exites.
here is the code.

func GuardAthenaService(name string) {

    for true {

        cur_dir, err := oss_utils.GetCurrentDirectory()
        if err != nil {
            oss_logger.Errorf("Fail to get current runing dir, err_desc=%s", err.Error())
            continue
        }

        bin := filepath.Join(cur_dir, name)
        conf := filepath.Join(cur_dir, fmt.Sprintf("../config/%s.yml", name))
        cmd := exec.Command(bin, "-c", conf)
        oss_logger.Infof("Athena start %v", cmd)
        cmdOutput, err := cmd.CombinedOutput()
        if err != nil {
            oss_logger.Errorf("%s service out put %s", name, cmdOutput)
            oss_logger.Errorf("%s service failed:%s,service restart", name, err.Error())
        }
        time.Sleep(5 * time.Second)
    }
}

func main() {

    ...........
    go GuardAthenaService("athena-keeper")
    go GuardAthenaService("athena-sentinel")

    .............
}

What did you see instead?

I used ps to find that process had already exited, but it did not restart.I looks like it got struck.
It did not happened under x86 so I think it might have something to do under s390x platform.
I used go tool routine, traces and found this.

runtime.gopark
runtime.goparkunlock
runtime.chanrecv
runtime.chanrecv1
os/exec.(*Cmd).Wait
os/exec.(*Cmd).Run
os/exec.(*Cmd).CombinedOutput
main.GuardAthenaService

It looks like that it's waiting for chan in io.Copy to finish .
unfortunately when I wanted to use delve to go deeper but found that it does not support s390x and gdb with go support can't watch variables the goroutine which is not running and it has it's own problem under s390x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions