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: program panics if receive other signal #21008

Closed
anotherGoogleFan opened this issue Jul 14, 2017 · 1 comment
Closed

runtime: program panics if receive other signal #21008

anotherGoogleFan opened this issue Jul 14, 2017 · 1 comment

Comments

@anotherGoogleFan
Copy link

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.3 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/vlion/GoProject"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build894970391=/tmp/go-build"
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?

simple code:

package main

import (
	"os"
	"os/signal"

	"github.com/anotherGoogleFan/log"
)

func main() {
	stopChan := make(chan os.Signal)
	signal.Notify(stopChan, os.Interrupt, os.Kill)
	<-stopChan
	log.Info("receive shutdown signal. Ready to exist")
}

and I build it, and run the binary. For example, it's pid is 822. And I run kill -3 822

What did you expect to see?

Nothing. Program hold and wait

What did you see instead?

SIGQUIT: quit
PC=0x457133 m=2 sigcode=0

goroutine 0 [idle]:
runtime.futex(0x782f78, 0x0, 0x7f16b39dbd28, 0x0, 0x7f1600000000, 0x456dc6, 0x3c, 0x0, 0x7f16b39dbd70, 0x40ec80, ...)
	/usr/local/go/src/runtime/sys_linux_amd64.s:426 +0x23
runtime.futexsleep(0x782f78, 0x0, 0xdf8475800)
	/usr/local/go/src/runtime/os_linux.go:62 +0xd7
runtime.notetsleep_internal(0x782f78, 0xdf8475800, 0x0)
	/usr/local/go/src/runtime/lock_futex.go:174 +0xd0
runtime.notetsleep(0x782f78, 0xdf8475800, 0x8)
	/usr/local/go/src/runtime/lock_futex.go:194 +0x56
runtime.sysmon()
	/usr/local/go/src/runtime/proc.go:3805 +0x135
runtime.mstart1()
	/usr/local/go/src/runtime/proc.go:1179 +0x11e
runtime.mstart()
	/usr/local/go/src/runtime/proc.go:1149 +0x64

goroutine 1 [chan receive]:
main.main()
	/home/vlion/src/main.go:13 +0xe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1

goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
	/usr/local/go/src/runtime/sigqueue.go:116 +0x104
os/signal.loop()
	/usr/local/go/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.1
	/usr/local/go/src/os/signal/signal_unix.go:28 +0x41

goroutine 6 [select, locked to thread]:
runtime.gopark(0x66ec38, 0x0, 0x66068e, 0x6, 0x18, 0x2)
	/usr/local/go/src/runtime/proc.go:271 +0x13a
runtime.selectgoImpl(0xc420032f50, 0x0, 0x18)
	/usr/local/go/src/runtime/select.go:423 +0x1364
runtime.selectgo(0xc420032f50)
	/usr/local/go/src/runtime/select.go:238 +0x1c
runtime.ensureSigM.func1()
	/usr/local/go/src/runtime/signal_unix.go:434 +0x2dd
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1

rax    0xfffffffffffffffc
rbx    0x0
rcx    0xffffffffffffffff
rdx    0x0
rdi    0x782f78
rsi    0x0
rbp    0x7f16b39dbd38
rsp    0x7f16b39dbcf0
r8     0x0
r9     0x0
r10    0x7f16b39dbd28
r11    0x246
r12    0x7fffd0871f00
r13    0x7f16b39dc9c0
r14    0x0
r15    0x3
rip    0x457133
rflags 0x246
cs     0x33
fs     0x0
gs     0x0
@anotherGoogleFan
Copy link
Author

Eh... I see the reason now.

@mikioh mikioh changed the title program panics if receive other signal runtime: program panics if receive other signal Jul 21, 2017
@golang golang locked and limited conversation to collaborators Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants