-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: go 1.6 (linux/amd64) segfault with musl libc #14851
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
I think it happens because alpine has a hardenend toolchain that will use PIE by default. We use this patch on Alpine go package: diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 8ccbec9dd634..4e96bfadc260 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1194,6 +1194,11 @@ func hostlink() {
argv = append(argv, peimporteddlls()...)
}
+ // The Go linker does not currently support building PIE
+ // executables when using the external linker. See:
+ // https://github.com/golang/go/issues/6940
+ argv = append(argv, "-fno-PIC")
+
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "host link:")
for _, v := range argv { And i tested the docker image with or without it. The patch is needed. |
The Alpine toolchain enables PIE by default. Since the go linker does not (yet) support PIE we need to explicitly disable it on Alpine. This is a workaround for golang/go#14851
Has there been a CL to attempt to fix this in a way that doesn't require patching the Go source to hard-code |
There is an open issue for that #6940 but it will likely not be implemented for go 1.6. Meanwhile, since go does not support PIE, I´d say it is correct to explicitly disable linking with PIE instead of relying on default behaviour of linker. |
The Alpine toolchain enables PIE by default. Since the go linker does not (yet) support PIE we need to explicitly disable it on Alpine. This is a workaround for golang/go#14851
Signed-off-by: Ying Li <[email protected]>
@ncopa Sorry for the long time without response - that seems to fix it for me, thanks! Do you think this issue should be closed since #6940 exists and docker-library/golang#91 has been merged? |
Yeah, I'll close this. |
Signed-off-by: Ying Li <[email protected]>
Signed-off-by: Ying Li <[email protected]>
Signed-off-by: Ying Li <[email protected]>
Signed-off-by: Ying Li <[email protected]>
I am running into a similar issue to #14476 (comment) where the binary I compile using go 1.6 using musl (https://github.com/mattes/migrate, which depends upon https://github.com/mattn/go-sqlite3, which may just have some problematic CGO, but I don't know what to look for) is segfaulting during runtime. To reproduce:
Here's the version of Go and the env on that image:
Here are the strace and GDB results:
Output from running
gdb /go/bin/migrate
:The 1.6.0-alpine image is based on alpine3.3. In case you wanted to use the ISO to replicate instead, maybe http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.3/releases/x86_64/alpine-3.3.1-x86_64.iso will work?
The text was updated successfully, but these errors were encountered: