Skip to content

runtime/metrics: example panics when histogram has no counts  #44148

@changkun

Description

@changkun

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

$ go version
go version devel +724d0720b3 Fri Feb 5 23:13:11 2021 +0000 darwin/arm64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/changkun/Library/Caches/go-build"
GOENV="/Users/changkun/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/changkun/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/changkun/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/changkun/dev/godev/go-github"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/changkun/dev/godev/go-github/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="devel +724d0720b3 Fri Feb 5 23:13:11 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/changkun/dev/godev/go-gerrit/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/g2/6fmr1qzx0ns3shq74zrp6bd40000gn/T/go-build3006232810=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://play.golang.org/p/sbvA_ODWDWu

What did you expect to see?

Run success

What did you see instead?

$ go run main.go
/gc/cycles/automatic:gc-cycles
/gc/cycles/automatic:gc-cycles: 0
/gc/cycles/forced:gc-cycles
/gc/cycles/forced:gc-cycles: 0
/gc/cycles/total:gc-cycles
/gc/cycles/total:gc-cycles: 0
/gc/heap/allocs-by-size:bytes
/gc/heap/allocs-by-size:bytes: 9.000000
/gc/heap/frees-by-size:bytes
panic: should not happen

goroutine 1 [running]:
main.medianBucket(0x140001061e0, 0x1c)
        /Users/changkun/dev/changkun.de/tests/metrics/main.go:64 +0xb8
main.main()
        /Users/changkun/dev/changkun.de/tests/metrics/main.go:35 +0x308
exit status 2

cc @mknyszek

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions