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

time: problematic time.Sleep on ARM (raspberry pi) #20878

Closed
analogic opened this issue Jul 1, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@analogic
Copy link

commented Jul 1, 2017

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

@davecheney

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2017

@ALTree ALTree changed the title problematic time.Sleep on ARM (raspberry pi) time: problematic time.Sleep on ARM (raspberry pi) Jul 1, 2017

@bradfitz bradfitz added this to the Unplanned milestone Jul 1, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Aug 1, 2017

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.)

@gopherbot gopherbot closed this Aug 1, 2017

@golang golang locked and limited conversation to collaborators Aug 1, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.