-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: -buildmode=pie -linkshared panic at runtime #47873
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
Comments
Possibly related: #25970 |
Function fmt.Printf is inlined. The actually called function is fmt.Fprintf, and the first arg is an ifcae, the data of it is _ -> main.main _ -> main..inittask _ -> runtime.unreachableMethod main.main -> os.Stdout main.main -> go.itab.*os.File,io.Writer main.main -> go.string."Hello, World!\n" main.main -> fmt.Fprintf main.main -> runtime.morestack_noctxt main.main -> gclocals·33cdeccccebe80329f1fdbee7f5874cb -> go.info.fmt.Printf$abstract go.itab.*os.File,io.Writer -> type.io.Writer go.itab.*os.File,io.Writer -> type.*os.File main..inittask -> fmt..inittask go.info.fmt.Printf$abstract -> go.info.string go.info.fmt.Printf$abstract -> go.info.[]interface {} go.info.fmt.Printf$abstract -> go.info.int go.info.fmt.Printf$abstract -> go.info.error It shows that type.*os.File is marked as "UsedInIface" in deadcode. But the symbol "type.*os.File" is in libstd.so. the method 'Write' of type.*os.File don't be marked as reachable. So the field fun of 'go.itab.*os.File,io.Writer' will be a weak reference. In function relocsym, the fun of 'go.itab.*os.File,io.Writer' will be reloced to "runtime.unreachableMethod" |
Change https://golang.org/cl/350189 mentions this issue: |
Can you review this CL when you're free? |
@gopherbot please consider this for backport to 1.17, maybe we need fix it for 1.17. |
Backport issue(s) opened: #49086 (for 1.17). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
What version of Go are you using (
go version
)?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
OutputWhat 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
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
The text was updated successfully, but these errors were encountered: