Skip to content

cmd/link: function "decodetypeGcmask" read gcdata from shared object file may not correct when use lld link in linux/arm64 #69466

@And-ZJ

Description

@And-ZJ

Go version

go version go1.23.1 linux/arm64

Output of go env in your module/workspace:

GO111MODULE='auto'
GOARCH='arm64'
GOBIN=''
GOCACHE='/usr1/GOCACHE'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/usr1/GOPATH/pkg/mod'
GOOS='linux'
GOPATH='/usr1/GOPATH'
GOROOT='/usr1/GoRelease/go1.23.1'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr1/GoRelease/go1.23.1/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD=''
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 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/usr1/tmp/go-build503891466=/tmp/go-build -gno-record-gcc-switches'

What did you do?

temp.go file:

package main

import (
	"errors"
	"runtime"
)

var err error

func main() {
	err = errors.New("111")
	runtime.GC()
	runtime.GC()
	runtime.GC()

	if err == nil {
		panic("err == nil")
	}
	if s := err.Error(); s != "111" {
		println(err)
		println(s)
		panic("s!=111")
	}
}
LLVM=/your_llvm_path
CC=$LLVM/bin/clang CXX=$LLVM/bin/clang++ go install -a -ldflags="-extldflags=-fuse-ld=lld" -buildmode=shared runtime sync/atomic
CC=$LLVM/bin/clang CXX=$LLVM/bin/clang++ go build -a -ldflags="-extldflags=-fuse-ld=lld" -linkshared temp.go
GODEBUG=clobberfree=1 ./temp

What did you see happen?

(0xaaaacd007078,0x400011c010)

panic: s!=111

goroutine 1 [running]:
main.main()
	/usr1/temp/temp.go:22 +0x14c

or

(0xaaaae0687078,0x4000196010)
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x2 addr=0x4000400000 pc=0xffff93014fe8]

goroutine 1 gp=0x40000041c0 m=5 mp=0x4000100008 [running]:
runtime.throw({0xffff92f353d7?, 0x0?})
	/usr1/GoRelease/go1.23.1/src/runtime/panic.go:1067 +0x38 fp=0x40000be5c0 sp=0x40000be590 pc=0xffff92fcade8
runtime.sigpanic()
	/usr1/GoRelease/go1.23.1/src/runtime/signal_unix.go:884 +0x378 fp=0x40000be620 sp=0x40000be5c0 pc=0xffff92fee308
runtime.memmove()
	/usr1/GoRelease/go1.23.1/src/runtime/memmove_arm64.s:159 +0x168 fp=0x40000be630 sp=0x40000be630 pc=0xffff93014fe8
runtime.recordForPanic({0x4000180000, 0x3915fe458886ea, 0x3915fe458886ea})
	/usr1/GoRelease/go1.23.1/src/runtime/print.go:45 +0x124 fp=0x40000be670 sp=0x40000be630 pc=0xffff92fce5f4
runtime.gwrite({0x4000180000, 0x3915fe458886ea, 0x1?})
	/usr1/GoRelease/go1.23.1/src/runtime/print.go:89 +0x2c fp=0x40000be6b0 sp=0x40000be670 pc=0xffff92fce76c
runtime.printstring({0x4000180000?, 0x4000196010?})
	/usr1/GoRelease/go1.23.1/src/runtime/print.go:246 +0x4c fp=0x40000be700 sp=0x40000be6b0 pc=0xffff92fcef3c
main.main()
	/usr1/temp/temp.go:21 +0x130 fp=0x40000be740 sp=0x40000be700 pc=0xaaaae0673a30
runtime.main()
	/usr1/GoRelease/go1.23.1/src/runtime/proc.go:272 +0x2e4 fp=0x40000be7d0 sp=0x40000be740 pc=0xffff92fcf694
runtime.goexit({})
	/usr1/GoRelease/go1.23.1/src/runtime/asm_arm64.s:1223 +0x4 fp=0x40000be7d0 sp=0x40000be7d0 pc=0xffff93013f24

What did you expect to see?

no crash.

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions