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

runtime: os/exec fatal error: all goroutines are asleep - deadlock! on mips64 #42825

Open
jgbooks opened this issue Nov 25, 2020 · 6 comments
Open
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jgbooks
Copy link

jgbooks commented Nov 25, 2020

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

$ go version
>go version go1.15.1 

Does this issue reproduce with the latest release?

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

go env Output
$ go env
running env
Kernel version:4.4.131
Architecture:          mips64
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3

What did you do?

package main

import (
	"os/exec"
	"strconv"
	"strings"
	"os"
	"log"
	"time"
)

// Check root rights to use system service
func checkPrivileges() (bool) {
	if output, err := exec.Command("id", "-g").Output(); err == nil {
		if gid, parseErr := strconv.ParseUint(strings.TrimSpace(string(output)), 10, 32); parseErr == nil {
			if gid == 0 {
				return true
			}
			return false
		}
	} else {
		// TODO: This is not true for user services.
		return os.Getppid() != 1
	}
	return false
}

func main(){
	log.SetFlags(log.Lshortfile|log.Ltime)
	checkPrivileges()
	time.Sleep(10*time.Second)
}

CGO_ENABLED=0 GOARCH=mips64le GOMIPS=softfloat GOOS=linux go build command.go

What did you expect to see?

What did you see instead?

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
os/exec.(*Cmd).Wait(0xc0000c4000, 0x0, 0x0)
	/usr/local/go/src/os/exec/exec.go:515 +0x128
os/exec.(*Cmd).Run(0xc0000c4000, 0xc0000c2050, 0x0)
	/usr/local/go/src/os/exec/exec.go:341 +0x74
os/exec.(*Cmd).Output(0xc0000c4000, 0x2, 0xc0000a0f58, 0x1, 0x1, 0xc0000c4000)
	/usr/local/go/src/os/exec/exec.go:546 +0xa4
main.checkPrivileges(0xc0000c2000)
	/root/client/debug/command.go:14 +0x8c
main.main()
	/root/client/debug/command.go:30 +0x54

goroutine 19 [IO wait]:
internal/poll.runtime_pollWait(0xffca558d28, 0x72, 0x118420)
	/usr/local/go/src/runtime/netpoll.go:220 +0x60
internal/poll.(*pollDesc).wait(0xc0000be258, 0x72, 0xc000058001, 0x8000, 0x8000)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x50
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc0000be240, 0xc000058000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
	/usr/local/go/src/internal/poll/fd_unix.go:159 +0x1c4
os.(*File).read(...)
	/usr/local/go/src/os/file_posix.go:31
os.(*File).Read(0xc0000bc038, 0xc000058000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
	/usr/local/go/src/os/file.go:116 +0x7c
io.copyBuffer(0x1183a0, 0xc0000c2050, 0x1182e0, 0xc0000bc038, 0xc000058000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
	/usr/local/go/src/io/io.go:409 +0x108
io.Copy(...)
	/usr/local/go/src/io/io.go:368
os/exec.(*Cmd).writerDescriptor.func1(0x0, 0x0)
	/usr/local/go/src/os/exec/exec.go:311 +0x70
os/exec.(*Cmd).Start.func1(0xc0000c4000, 0xc0000ae0c0)
	/usr/local/go/src/os/exec/exec.go:441 +0x3c
created by os/exec.(*Cmd).Start
	/usr/local/go/src/os/exec/exec.go:440 +0x454
@ALTree ALTree changed the title mips64:os/exec fatal error: all goroutines are asleep - deadlock! runtime: os/exec fatal error: all goroutines are asleep - deadlock! on mips64 Nov 25, 2020
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 25, 2020
@ianlancetaylor ianlancetaylor added this to the Go1.16 milestone Nov 25, 2020
@ianlancetaylor
Copy link
Contributor

Does the program fail quickly, or does it wait for 10 seconds?

Is it possible for you to test this with Go tip? Thanks.

Please also include the output of running go env. The output you showed is from some other program. Thanks.

@jgbooks
Copy link
Author

jgbooks commented Nov 26, 2020

it fail quickly.
Before that, I compiled in AMD64, running on MIPS64

I try to build an go1.5.5 environment on MIPS64,The following problems occurred

root@topdesk-os:/home# go env
warning: GOPATH set to GOROOT (/usr/local/go) has no effect
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
os/exec.(*Cmd).Wait(0xc000140000, 0x0, 0x0)
	/opt/go-linux-mips64le-bootstrap/src/os/exec/exec.go:515 +0x128
os/exec.(*Cmd).Run(0xc000140000, 0xc0001062d0, 0xc000110580)
	/opt/go-linux-mips64le-bootstrap/src/os/exec/exec.go:341 +0x74
os/exec.(*Cmd).CombinedOutput(0xc000140000, 0xc00010e2c0, 0x2c, 0x2c, 0x2d, 0xc000110580)
	/opt/go-linux-mips64le-bootstrap/src/os/exec/exec.go:567 +0xbc
cmd/go/internal/work.(*Builder).gccSupportsFlag(0xc00011e3c0, 0xc00011c060, 0x1, 0x1, 0x6793cb, 0x16, 0x0)
	/opt/go-linux-mips64le-bootstrap/src/cmd/go/internal/work/exec.go:2466 +0x4e8
cmd/go/internal/work.(*Builder).compilerCmd(0xc00011e3c0, 0xc00011c060, 0x1, 0x1, 0x66d59d, 0x1, 0x0, 0x0, 0xc00010aa00, 0xc00010a9a0, ...)
	/opt/go-linux-mips64le-bootstrap/src/cmd/go/internal/work/exec.go:2375 +0x420
cmd/go/internal/work.(*Builder).GccCmd(0xc00011e3c0, 0x66d59d, 0x1, 0x0, 0x0, 0xc00010a9a0, 0x2, 0x2)
	/opt/go-linux-mips64le-bootstrap/src/cmd/go/internal/work/exec.go:2301 +0x6c
cmd/go/internal/envcmd.ExtraEnvVarsCostly(0x603200, 0xc000110360, 0x1)
	/opt/go-linux-mips64le-bootstrap/src/cmd/go/internal/envcmd/env.go:166 +0x1e0
cmd/go/internal/envcmd.runEnv(0x9f5640, 0xc00000a0d0, 0x0, 0x0)
	/opt/go-linux-mips64le-bootstrap/src/cmd/go/internal/envcmd/env.go:222 +0x1258
main.main()
	/opt/go-linux-mips64le-bootstrap/src/cmd/go/main.go:190 +0x858

goroutine 17 [IO wait]:
internal/poll.runtime_pollWait(0xffc1da0e88, 0x72, 0x73cca0)
	/opt/go-linux-mips64le-bootstrap/src/runtime/netpoll.go:222 +0x60
internal/poll.(*pollDesc).wait(0xc00013c0d8, 0x72, 0x73cc01, 0x9b03e0, 0x0)
	/opt/go-linux-mips64le-bootstrap/src/internal/poll/fd_poll_runtime.go:87 +0x50
internal/poll.(*pollDesc).waitRead(...)
	/opt/go-linux-mips64le-bootstrap/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc00013c0c0, 0xc000022646, 0x5ba, 0x5ba, 0x0, 0x0, 0x0)
	/opt/go-linux-mips64le-bootstrap/src/internal/poll/fd_unix.go:159 +0x1c0
os.(*File).read(...)
	/opt/go-linux-mips64le-bootstrap/src/os/file_posix.go:31
os.(*File).Read(0xc00010c028, 0xc000022646, 0x5ba, 0x5ba, 0x46, 0x0, 0x0)
	/opt/go-linux-mips64le-bootstrap/src/os/file.go:116 +0x7c
bytes.(*Buffer).ReadFrom(0xc0001062d0, 0x73bfc0, 0xc00010c028, 0xffc1dea998, 0xc0001062d0, 0x1)
	/opt/go-linux-mips64le-bootstrap/src/bytes/buffer.go:204 +0xcc
io.copyBuffer(0x73b320, 0xc0001062d0, 0x73bfc0, 0xc00010c028, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/opt/go-linux-mips64le-bootstrap/src/io/io.go:395 +0x338
io.Copy(...)
	/opt/go-linux-mips64le-bootstrap/src/io/io.go:368
os/exec.(*Cmd).writerDescriptor.func1(0x0, 0x0)
	/opt/go-linux-mips64le-bootstrap/src/os/exec/exec.go:311 +0x70
os/exec.(*Cmd).Start.func1(0xc000140000, 0xc00010ab60)
	/opt/go-linux-mips64le-bootstrap/src/os/exec/exec.go:441 +0x3c
created by os/exec.(*Cmd).Start
	/opt/go-linux-mips64le-bootstrap/src/os/exec/exec.go:440 +0x454

@jgbooks
Copy link
Author

jgbooks commented Dec 10, 2020

@ianlancetaylor
I found that this version works of "go version go1.13.15 linux/amd64".
When I have time, I'll find out why

@jgbooks
Copy link
Author

jgbooks commented Dec 10, 2020

I tired 1.14.2,and1.15.x, this is not work. only 1.13.15 works

@odeke-em
Copy link
Member

odeke-em commented Feb 7, 2021

Thanks for the report @jgbooks. I shall triage this for Go1.17, and mark it as needing investigation.

@odeke-em odeke-em modified the milestones: Go1.16, Go1.17 Feb 7, 2021
@dmitshur
Copy link
Contributor

dmitshur commented May 21, 2021

We may not get to resolve this in Go 1.17, so moving to Backlog for now.

@dmitshur dmitshur modified the milestones: Go1.17, Backlog May 21, 2021
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: Triage Backlog
Development

No branches or pull requests

5 participants