Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.21.0 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE='auto' GOARCH='amd64' GOBIN='' GOCACHE='/Users//Library/Caches/go-build' GOENV='/Users//Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users//go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users//go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/local/Cellar/go/1.21.0/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/local/Cellar/go/1.21.0/libexec/pkg/tool/darwin_amd64' GOVCS='' GOVERSION='go1.21.0' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/Users//code///go.mod' GOWORK='/Users//code//go.work' 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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/hy/sxcwypzn0h9bg08bpjz789y00000gn/T/go-build2316893392=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
cd project
go run .
The same thing happens with go build .
.
What did you expect to see?
My program running the same way it did on 1.20
What did you see instead?
# gitlab.com/<org>/<repo>/<project>
panic: runtime error: slice bounds out of range [74:69]
goroutine 1 [running]:
cmd/link/internal/ld.typeSymbolMangle({0x49ac657b, 0x4f})
/usr/local/Cellar/go/1.21.0/libexec/src/cmd/link/internal/ld/lib.go:1012 +0x379
cmd/link/internal/ld.(*Link).mangleTypeSym(0xc000110000)
/usr/local/Cellar/go/1.21.0/libexec/src/cmd/link/internal/ld/lib.go:959 +0xb9
cmd/link/internal/ld.Main(_, {0x20, 0x20, 0x1, 0x7, 0x10, 0x0, {0xc0000ae2e9, 0x1, 0x1}, ...})
/usr/local/Cellar/go/1.21.0/libexec/src/cmd/link/internal/ld/main.go:308 +0x124b
main.main()
/usr/local/Cellar/go/1.21.0/libexec/src/cmd/link/main.go:72 +0xdfb
I have confirmed that a simple hello world program does work so there must be something specific to the code or project environment.
I searched for the same issue and found #61060 but this seemed too different to lump in with that, and it's happening on the latest release.
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]link: slice bounds out of range[/-][+]cmd/link: slice bounds out of range[/+]dmitshur commentedon Aug 17, 2023
Are you able to provide more information on how this panic can be reproduced?
cd project; go run .
doesn't have enough context to investigate this issue.swtch1 commentedon Aug 17, 2023
I agree, but it's a large project with too much code to share. Here are some extra details. Let me know what other information I can provide.
This is the build commands (not all of them) from right before the panic.
This is the call graph dumped (not the whole thing) from right before the panic.
go.mod:
cherrymui commentedon Aug 17, 2023
That code is
To have such a slice out of bounds error, the symbol name would be something like
...]...[...
with unmatched brackets. I don't see why a symbol would have such a name. Maybe a non-Go symbol?The linker code could be more defensive on that. It would be good to see an example of such symbol, though.
swtch1 commentedon Aug 17, 2023
I've found something. The program builds if I comment this code
Though I am unable to reproduce the error in a sample program.
cherrymui commentedon Aug 18, 2023
Thanks. A simple reproducer is
We need to use plugin (or build as a plugin) to trigger the symbol name mangling.
The offensive symbol is
go:string."&$@;/:+,?\\{^}%``]\">[~<#|"
for the string literal. There is probably no need to mangle that symbol name as string symbols will not be in the final executable's symbol table.jimmson commentedon Aug 18, 2023
Might be related, we are seeing a similar issue: #62131
13 remaining items