Skip to content

cmd/trace: pcs overflow would panic #78538

@cuiweixie

Description

@cuiweixie

Go version

go version go1.26.1 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/cui/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/cui/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/78/tfh4ck1s0nv0h4ztpq0l8x8m0000gn/T/go-build431903214=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/cui/code/goroot/gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/cui/code/goroot/gopath'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/cui/code/goroot/go1.26.1/go'
GOSUMDB='off'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/cui/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/cui/code/goroot/go1.26.1/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.26.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

run the regression test:

func TestFillPCsOverflow(t *testing.T) {
	var pcs [pprofMaxStack]uint64

	// Build a slice of frames larger than pprofMaxStack.
	n := pprofMaxStack + 10
	frames := make([]itrace.StackFrame, n)
	for i := range frames {
		frames[i].PC = uint64(0x1000 + i)
	}

	// This must not panic.
	fillPCs(frames, &pcs)

	// Verify the first pprofMaxStack entries were written correctly.
	for i := 0; i < pprofMaxStack; i++ {
		if pcs[i] != uint64(0x1000+i) {
			t.Errorf("pcs[%d] = %#x, want %#x", i, pcs[i], 0x1000+i)
		}
	}
}

What did you see happen?

panic

What did you expect to see?

don't panic

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions