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

cmd/compile: too many ? in tracebacks #64414

Closed
randall77 opened this issue Nov 28, 2023 · 3 comments
Closed

cmd/compile: too many ? in tracebacks #64414

randall77 opened this issue Nov 28, 2023 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@randall77
Copy link
Contributor

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

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Nov 28, 2023
@randall77
Copy link
Contributor Author

This looks like a bug in the type given to slice pointers by expand_calls. The location of the stack slot has type *int, but the ssa Value has type *uint8. The compiler refuses to use a stack slot that isn't typed correctly.

I have a simple fix. Just working on a test.

@dr2chase

@randall77
Copy link
Contributor Author

(Probably a side-effect of expand calls cleanup.)

@randall77 randall77 self-assigned this Nov 28, 2023
@randall77 randall77 added this to the Go1.22 milestone Nov 28, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/545357 mentions this issue: cmd/compile: use correct type for slice pointer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

2 participants