Skip to content

cmd/link: -buildmode=pie -linkshared panic at runtime #47873

Closed
@kiap

Description

@kiap

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

$ go version

go version go1.17 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

Linux x86_64 both CentOS 7.9 and RHEL 8.4

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/src/.cache"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/usr/src/dev/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/src/dev"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/src/dev"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/src/dev/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/usr/src/dev/src/hello/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build919601769=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Building a simple hello program with shared library

go install -v -ldflags '-s -w' -buildmode=shared -linkshared -pkgdir /usr/src/lib std
go install -v -ldflags '-s -w' -buildmode=pie -linkshared -pkgdir /usr/src/lib hello

package main

import  (
              "fmt"
)
func main() {
           fmt.Printf("Hello, World!\n")
}

What did you expect to see?

Hello, World!

What did you see instead?

fatal error: unreachable method called. linker bug?

goroutine 1 [running]:
runtime.throw({0x7f77de5db273, 0xc00034c708})
/usr/src/dev/src/runtime/panic.go:1198 +0x71 fp=0xc00035aeb8 sp=0xc00035ae88 pc=0x7f77ddead251
runtime.unreachableMethod()
/usr/src/dev/src/runtime/iface.go:561 +0x25 fp=0xc00035aed8 sp=0xc00035aeb8 pc=0x7f77dde77ea5
fmt.Fprintf({0x5616a7877b48, 0xc0003ae008}, {0x5616a76771e0, 0xe}, {0x0, 0x0, 0x0})
/usr/src/dev/src/fmt/print.go:205 +0x9b fp=0xc00035af38 sp=0xc00035aed8 pc=0x7f77ddfc0ddb
fmt.Printf(...)
/usr/src/dev/src/fmt/print.go:213
()
src/hello/hello.go:10 +0x3e fp=0xc00035af80 sp=0xc00035af38 pc=0x5616a767711e
runtime.main()
/usr/src/dev/src/runtime/proc.go:255 +0x282 fp=0xc00035afe0 sp=0xc00035af80 pc=0x7f77ddeb0902
runtime.goexit()
/usr/src/dev/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00035afe8 sp=0xc00035afe0 pc=0x7f77ddee93a1

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions