You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran and built the included program like this:
GOMAXPROCS=4 GODEBUG=schedtrace=1000 ./threads
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
rspillane@ubuntu:/tmp$ cat threads.go
package main
import (
"time"
)
func main() {
baubles := make(chan bool, 1024)
for {
baubles <- true
go func() {
busycounter := 0
for {
select {
case <-time.After(time.Millisecond):
break
default:
busycounter += 1
}
}
<-baubles
}()
}
}
What did you expect to see?
It should run forever and consume all my CPU and a little RAM (1-4KB per thread times 1024 threads, so several MBs).
What did you see instead?
The kernel would kill my process sometimes. Other times the process would crash with many many backtraces because it ran out of memory somewhere else. Back-trace of the many-many-backtrace case included (when the kernel kills it it just prints 'Killed').
the break is breaking out of the select, not the for loop
on each iteration of the inner loop, you will create a timer, go into the default case, then repeat the inner loop, which allocates an immense number of timers until you run out of memory.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8 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/rspillane/go"
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-build478482962=/tmp/go-build -gno-record-gcc-switches"
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 ran and built the included program like this:
GOMAXPROCS=4 GODEBUG=schedtrace=1000 ./threads
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
It should run forever and consume all my CPU and a little RAM (1-4KB per thread times 1024 threads, so several MBs).
What did you see instead?
The kernel would kill my process sometimes. Other times the process would crash with many many backtraces because it ran out of memory somewhere else. Back-trace of the many-many-backtrace case included (when the kernel kills it it just prints 'Killed').
threads.go puking.txt
The text was updated successfully, but these errors were encountered: