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/link: index out of range at cmd/link/internal/ld.decodetypeKind #62156

Closed
johejo opened this issue Aug 19, 2023 · 7 comments
Closed

cmd/link: index out of range at cmd/link/internal/ld.decodetypeKind #62156

johejo opened this issue Aug 19, 2023 · 7 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@johejo
Copy link

johejo commented Aug 19, 2023

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

$ go version
go version devel go1.22-a9859a7df7 Fri Aug 18 23:45:44 2023 +0000 linux/amd64

Does this issue reproduce with the latest release?

no, tip only

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

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/mitsuoheijo/.cache/go-build'
GOENV='/home/mitsuoheijo/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/mitsuoheijo/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/mitsuoheijo/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/mitsuoheijo/repos/github.com/golang/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/mitsuoheijo/repos/github.com/golang/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.22-a9859a7df7 Fri Aug 18 23:45:44 2023 +0000'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/mitsuoheijo/repos/github.com/osrg/gobgp/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build811026688=/tmp/go-build -gno-record-gcc-switches'

What did you do?

git clone https://github.com/osrg/gobgp.git
cd gobgp/
git checkout v3.17.0
go build ./cmd/gobgpd

What did you expect to see?

build succeeds

What did you see instead?

# github.com/osrg/gobgp/v3/cmd/gobgpd
type:func([]github.com/osrg/gobgp/v3/pkg/packet/bgp.ExtendedCommunityInterface) []github.com/osrg/gobgp/v3/pkg/packet/bgp.ExtendedCommunityInterface: missing type
panic: runtime error: index out of range [23] with length 0

goroutine 1 [running]:
cmd/link/internal/ld.decodetypeKind(...)
        /home/mitsuoheijo/repos/github.com/golang/go/src/cmd/link/internal/ld/decodesym.go:42
cmd/link/internal/ld.(*dwctxt).newtype(0xc001ef6948, 0x7a245)
        /home/mitsuoheijo/repos/github.com/golang/go/src/cmd/link/internal/ld/dwarf.go:546 +0x228a
cmd/link/internal/ld.(*dwctxt).defgotype(0xc001ef6948, 0x7a245)
        /home/mitsuoheijo/repos/github.com/golang/go/src/cmd/link/internal/ld/dwarf.go:534 +0x119
cmd/link/internal/ld.(*dwctxt).importInfoSymbol(0xc001ef6948, 0x4a00e)
        /home/mitsuoheijo/repos/github.com/golang/go/src/cmd/link/internal/ld/dwarf.go:1143 +0x345
cmd/link/internal/ld.(*dwctxt).dwarfVisitFunction(0xc001ef6948, 0x6?, 0xc0000b7040)
        /home/mitsuoheijo/repos/github.com/golang/go/src/cmd/link/internal/ld/dwarf.go:1723 +0x41f
cmd/link/internal/ld.dwarfGenerateDebugInfo(0xc00011e200)
        /home/mitsuoheijo/repos/github.com/golang/go/src/cmd/link/internal/ld/dwarf.go:1882 +0x148e
cmd/link/internal/ld.Main(_, {0x20, 0x20, 0x1, 0x7, 0x10, 0x0, {0xc000012469, 0x1, 0x1}, ...})
        /home/mitsuoheijo/repos/github.com/golang/go/src/cmd/link/internal/ld/main.go:356 +0x1332
main.main()
        /home/mitsuoheijo/repos/github.com/golang/go/src/cmd/link/main.go:72 +0xdfb

If disabling DWARF with -ldflags='-w' the link succeeds.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 19, 2023
@dmitshur
Copy link
Contributor

dmitshur commented Aug 19, 2023

Thanks for reporting.

CC @mdempsky, @cuonglm.

@dmitshur dmitshur added this to the Go1.22 milestone Aug 19, 2023
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 19, 2023
@mdempsky
Copy link
Member

Bisect identifies ca858a4.

@mdempsky mdempsky self-assigned this Aug 19, 2023
@gopherbot
Copy link

Change https://go.dev/cl/521155 mentions this issue: Revert "cmd/compile/internal/gc: steps towards work-queue"

@mdempsky
Copy link
Member

Confirmed that reverting that CL fixes the gobgpd build.

I'm fine with reverting and then rolling forward once the failure case is understood.

gopherbot pushed a commit that referenced this issue Aug 19, 2023
This reverts commit CL 520611.

Reason for revert: #62156.

Change-Id: Iebd17bdfc00824de3d5011a74d071a41c4fa06f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/521155
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
cellularmitosis pushed a commit to cellularmitosis/go that referenced this issue Aug 24, 2023
This reverts commit CL 520611.

Reason for revert: golang#62156.

Change-Id: Iebd17bdfc00824de3d5011a74d071a41c4fa06f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/521155
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
@mdempsky
Copy link
Member

The issue here is that DWARF generation can also produce references to runtime type descriptors, which need to be written out too. So that also needs to go into the work queue. Whee.

@mdempsky
Copy link
Member

Minimal repro:

package a

type iface interface{ m() }

func F() {
	f := func(rt []iface) []iface {
		return append([]iface{}, rt...)
	}
	f(nil)
}
package main

import "test/a"

func main() {
	a.F()
}

@johejo
Copy link
Author

johejo commented Oct 7, 2023

@johejo johejo closed this as completed Oct 7, 2023
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 7, 2023
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. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants