-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.8.3 linux/arm
What operating system and processor architecture are you using (go env)?
GOARCH="arm"
GOBIN=""
GOEXE=""
GOHOSTARCH="arm"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/pi/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm"
GCCGO="gccgo"
GOARM=""
CC="gcc"
GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0"
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?
I have simple loop which print global variables indefinitely with 1s sleep
for {
time.Sleep(time.Second * 1)
...print...
}What did you see instead?
Program will crash almost always after 6 hours with
runtime/cgo: pthread_create failed: Resource temporarily unavailable
SIGABRT: abort
PC=0x76d81f70 m=17 sigcode=4294967290
goroutine 0 [idle]:
goroutine 3 [running]:
runtime.systemstack_switch()
/usr/local/go/src/runtime/asm_arm.s:209 +0x4 fp=0x10826f70 sp=0x10826f6c
runtime.goready(0x1085e780, 0x0)
/usr/local/go/src/runtime/proc.go:283 +0x3c fp=0x10826f84 sp=0x10826f70
runtime.goroutineReady(0x304898, 0x1085e780, 0x0)
/usr/local/go/src/runtime/time.go:82 +0x34 fp=0x10826f94 sp=0x10826f84
runtime.timerproc()
/usr/local/go/src/runtime/time.go:196 +0x224 fp=0x10826fec sp=0x10826f94
runtime.goexit()
/usr/local/go/src/runtime/asm_arm.s:1017 +0x4 fp=0x10826fec sp=0x10826fec
created by runtime.addtimerLocked
/usr/local/go/src/runtime/time.go:116 +0x124
...
My workaround
I don't think that sleep in for loop is right way so I've refactored code to
ticker := time.NewTicker(1 * time.Second)
go func() {
for {
select {
case <-ticker.C:
printCurrent(w);
}
}
} ()and no crash since that time happened yet so it leads me to conclusion that there is something wrong in internals of sleep