Skip to content

cmd/compile: too many ? in tracebacks #64414

@randall77

Description

@randall77

Go version

tip

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

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/khr/Library/Caches/go-build'
GOENV='/Users/khr/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/khr/gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/khr/gopath'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/khr/sandbox/ro3'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/khr/sandbox/ro3/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='devel go1.22-e511c65dd3 Mon Nov 27 15:59:45 2023 -0800'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/khr/sandbox/ro3/src/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/z9/dty110711l9cr9w3ktv1_2380000gn/T/go-build1902989146=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

package main

//go:noinline
func f(a []int, i int) int {
	g()
	return a[i]
}

//go:noinline
func g() {
	panic("here")
}

func main() {
	var a [4]int
	println(f(a[:], 3))
}

When run, it prints

panic: here

goroutine 1 [running]:
main.g()
	/Users/khr/gowork/tmp1.go:13 +0x2c
main.f({0x14000064710?, 0x4, 0x14000064738?}, 0x3)
	/Users/khr/gowork/tmp1.go:6 +0x2c
main.main()
	/Users/khr/gowork/tmp1.go:18 +0x34

Note that the data pointer of the slice arg to f has a ? in it. It shouldn't, that arg is live across the call to g and the compiler puts it somewhere known.

	0x001c 00028 (/Users/khr/gowork/tmp1.go:8)	MOVD	R1, main.a+8(FP)
	0x0020 00032 (/Users/khr/gowork/tmp1.go:8)	MOVD	R0, main..autotmp_3-8(SP)
	0x0024 00036 (/Users/khr/gowork/tmp1.go:8)	MOVD	R3, main.i+24(FP)

Looks like the compiler is spilling the pointer to an autotmp, not the arg slot.

(It then also spills it to the arg slot at the start of the function, presumably to make tracebacks better? But that copy might be stale, which is probably why the ? is still there.)

What did you expect to see?

no question mark

What did you see instead?

a question mark

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions