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
cmd/link: panic: runtime error: invalid memory address or nil pointer dereference when using -buildmode=shared -linkshared on ppc64le #15770
Comments
How much of the -buildmode=shared -linkshared options should work with ppc64le? I see it is mentioned in the Go 1.6 release notes as being supported for ppc64le but I have not used it before. I've been trying various ways to use it but can't make it work. From looking through various documentation I need to make sure I have libstd.so, and possibly libcmd.so. When I try to build using -buildmode=shared I am getting errors like this: /home/boger/golang/ibm-go1.6/go/pkg/tool/linux_ppc64le/link -o $WORK/lib.so -L $WORK -installsuffix dynlink -buildmode=shared -X k8s.io/kubernetes/pkg/version.buildDate=2016-05-25T18:15:36Z -X k8s.io/kubernetes/pkg/version.gitCommit=025b0172774770f0d5eee3e9604c1a2d938976e0 -X k8s.io/kubernetes/pkg/version.gitTreeState=dirty -X k8s.io/kubernetes/pkg/version.gitVersion=v1.3.0-alpha.4.474+025b0172774770-dirty -X k8s.io/kubernetes/pkg/version.gitMajor=1 -X k8s.io/kubernetes/pkg/version.gitMinor=3+ -v -extldflags -Wl,--print-map -extld=powerpc64le-linux-gnu-gcc runtime/cgo=/home/boger/golang/ibm-go1.6/go/pkg/linux_ppc64le_dynlink/runtime/cgo.a sync/atomic.StorePointer: sync/atomic.StoreUintptr: not defined I can see that the symbol sync/atomic.StoreUintptr is in my libstd.so, but it is not finding it, unless I need to do something to get it to find it. |
It should work, but hasn't been deeply tested. I suspect that it's the -X I don't understand that second link failure, it seems to be trying to link On 26 May 2016 at 06:33, Lynn Boger notifications@github.com wrote:
|
I can't reproduce this (with the go 1.6.2 that's on yakkety):
I doubt something between 1.6.1 and 1.6.2 fixed this but who knows. On 26 May 2016 at 09:35, Michael Hudson-Doyle michael.hudson@canonical.com
|
Building kubernetes is new to me so I'm still learning about the makefiles and what should get built. And it seems to behave differently as commits are added to it, so the behavior is not consistent. If you pull from the latest then you must update the hack/lib/golang.sh file to enable builds for ppc64le. +++ b/hack/lib/golang.sh
@@ -79,7 +79,7 @@ else
The original error happens when building the hyperkube binary, and that error was a relocation truncation error due to the text section getting too large for the GNU linker to handle. After the original failure, in some later commits it does build successfully, it just depends on the size that it ends up being or the length for the branch targets. In any case, I was hoping that the use of -buildmode=shared -linkshared would resolve the original issue and allow the build to succeed but maybe that is a wrong assumption. In any case I would like to understand how the buildmode and linkshared options should be used in this case even if it doesn't solve my original problem. If the build of the hyperkube binary succeeds (without the -buildmode=shared -linkshared options) you should see these: Here's what I tried, and maybe I'm not using the options correctly. I first did: In my experiments, when I add -buildmode=shared -linkshared to 'go install' in golang.sh it doesn't build the hyperkube binary so it's not really doing what it needs to do. Not sure if that is expected when using those options. Any comments or advice would be helpful. |
@mwhudson I think I have found a real bug with the used of -linkshared and -buildmode and not sure if it is ppc64le only. I can change the title or close this one and open a new one. If std has been built as a shared library and you try to use -buildmode=shared -linkshared with something that imports golang.org/x/sys/unix, you will get errors like this: host link: "powerpc64le-linux-gnu-gcc" "-m64" "-gdwarf-2" "-Wl,-znow" "-o" "/tmp/go-build873207612/k8s.io/kubernetes/cmd/kubelet/_obj/exe/a.out" "-rdynamic" "/tmp/go-link-758373105/go.o" "/tmp/go-link-758373105/000000.o" "/tmp/go-link-758373105/000001.o" "/tmp/go-link-758373105/000002.o" "-L/home/boger/golang/go1.6/go/pkg/linux_ppc64le_dynlink/" "-Wl,-rpath=/home/boger/golang/go1.6/go/pkg/linux_ppc64le_dynlink/" "-lstd" "-g" "-O2" "-g" "-O2" "-g" "-O2" The instruction it is complaining about is a simple branch instruction. The asm code looks like this: TEXT ·Syscall(SB),NOSPLIT,$0-56 TEXT ·Syscall6(SB),NOSPLIT,$0-80 TEXT ·RawSyscall(SB),NOSPLIT,$0-56 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 The ppc64le asm is just a branch. |
Here is a simple way to reproduce the problem I found. There are actually two problems.
import ( func main() { I see multiple errors. command-line-arguments/home/boger/golang/go1.6/go/pkg/tool/linux_ppc64le/link: running gcc failed: exit status 1 |
same problem happened here in x86_64 with go 1.6.2 too. the problem looked like the same no matter with '-x' option or not. go install -buildmode=shared -linkshared -s -v -p 4 golang.org/x/text/... [ 53s] golang.org/x/text/unicode |
@laboger, what's the status here? Go1.10? |
I'm sorry I didn't see this sooner, sometimes I don't see the notifications for @laboger, not sure why or how to find out. I just tried this, it still fails. This needs to be compiled as position independent (-shared) but a direct branch to an external target like this is not what the ext linker expects in position independent code. It is the following BR instructions that it is complaining about. TEXT ·Syscall(SB),NOSPLIT,$0-56 TEXT ·Syscall6(SB),NOSPLIT,$0-80 TEXT ·RawSyscall(SB),NOSPLIT,$0-56 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 It should probably be done one way for PIC and another for non-PIC. |
I looked at this a bit... I think what needs to be done is if there is a BR (branch) with the target too far or in a different name space, then it needs to generate a code sequence like a trampoline, if compiled with -dynlink or -shared. |
Obsoleted by #47788 |
Please answer these questions before submitting your issue. Thanks!
go version
)?go version go1.6.1 linux/ppc64le
Also fails with latest from tip.
go env
)?Ubuntu 16.04
GOARCH="ppc64le"
GOBIN=""
GOEXE=""
GOHOSTARCH="ppc64le"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/lib/go-1.6"
GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_ppc64le"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Tried to build kubernetes
Successful build
Failed build.
First, with the cloned code as is, the error is: relocation truncated to fit: R_PPC64_REL24 from several lines due to the size of the packages and binary getting too large. I believe the use of shared libraries should help this problem, so I modified hack/lib/golang.sh to use -buildmode=shared and -linkshared.
go install "${goflags[@]:+${goflags[@]}}" -x -buildmode=shared -ldflags "${goldflags} -linkshared" "${nonstatics[@]:+${nonstatics[@]}}
After adding that I get this error:
/usr/lib/go-1.6/pkg/tool/linux_ppc64le/link -o $WORK/lib.so -L $WORK -installsuffix dynlink -buildmode=shared -X k8s.io/kubernetes/pkg/version.buildDate=2016-05-20T14:18:29Z -X k8s.io/kubernetes/pkg/version.gitCommit=b7a31ad2615524cefcb82ed4b3832e2105147410 -X k8s.io/kubernetes/pkg/version.gitTreeState=dirty -X k8s.io/kubernetes/pkg/version.gitVersion=v1.3.0-alpha.4.191+b7a31ad2615524-dirty -X k8s.io/kubernetes/pkg/version.gitMajor=1 -X k8s.io/kubernetes/pkg/version.gitMinor=3+ -linkshared -extld=powerpc64le-linux-gnu-gcc runtime/cgo=/usr/lib/go-1.6/pkg/linux_ppc64le_dynlink/runtime/cgo.a
//# /tmp/go-build298159653/lib.so
missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.buildDate size 16
missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitCommit size 16
missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitMajor size 16
missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitMinor size 16
missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitTreeState size 16
missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitVersion size 16
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x1172dc]
goroutine 1 [running]:
panic(0x260e40, 0xc82000e160)
/usr/lib/go-1.6/src/runtime/panic.go:464 +0x3a0
cmd/link/internal/ld.defgotype(0xc821609680, 0x12)
/usr/lib/go-1.6/src/cmd/link/internal/ld/dwarf.go:1101 +0x3adc
cmd/link/internal/ld.Dwarfemitdebugsections()
/usr/lib/go-1.6/src/cmd/link/internal/ld/dwarf.go:2120 +0x960
cmd/link/internal/ppc64.asmb()
/usr/lib/go-1.6/src/cmd/link/internal/ppc64/asm.go:905 +0x1308
cmd/link/internal/ld.Ldmain()
/usr/lib/go-1.6/src/cmd/link/internal/ld/pobj.go:248 +0x20f4
cmd/link/internal/ppc64.Main()
/usr/lib/go-1.6/src/cmd/link/internal/ppc64/obj.go:44 +0x28
main.main()
/usr/lib/go-1.6/src/cmd/link/main.go:36 +0x540
To reproduce:
git clone https://github.com/kubernetes/kubernetes.git
cd kubernetes
make
Similar error happens with go built from latest master but the stack is somewhat different. I did try removing the -X options to the link and the messages about "missing Go type... " didn't appear but the panic still happened.
/home/boger/golang/upstream/go/pkg/tool/linux_ppc64le/link -o $WORK/lib.so -L $WORK -installsuffix dynlink -buildmode=shared -X k8s.io/kubernetes/pkg/version.buildDate=2016-05-20T14:31:11Z -X k8s.io/kubernetes/pkg/version.gitCommit=b7a31ad2615524cefcb82ed4b3832e2105147410 -X k8s.io/kubernetes/pkg/version.gitTreeState=dirty -X k8s.io/kubernetes/pkg/version.gitVersion=v1.3.0-alpha.4.191+b7a31ad2615524-dirty -X k8s.io/kubernetes/pkg/version.gitMajor=1 -X k8s.io/kubernetes/pkg/version.gitMinor=3+ -linkshared -extld=powerpc64le-linux-gnu-gcc runtime/cgo=/home/boger/golang/upstream/go/pkg/linux_ppc64le_dynlink/runtime/cgo.a
//# /tmp/go-build839806022/lib.so
go.link.addmoduledata: missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.buildDate size 16
go.link.addmoduledata: missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitCommit size 16
go.link.addmoduledata: missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitMajor size 16
go.link.addmoduledata: missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitMinor size 16
go.link.addmoduledata: missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitTreeState size 16
go.link.addmoduledata: missing Go type information for global symbol: k8s.io/kubernetes/pkg/version.gitVersion size 16
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x101c84]
goroutine 1 [running]:
panic(0x1f6d00, 0xc420010120)
/home/boger/golang/upstream/go/src/runtime/panic.go:500 +0x3a8
cmd/link/internal/ld.newtype(0xc421fafee0, 0xc420012360)
/home/boger/golang/upstream/go/src/cmd/link/internal/ld/dwarf.go:998 +0x3ab4
cmd/link/internal/ld.defgotype(0xc421fafee0, 0x12)
/home/boger/golang/upstream/go/src/cmd/link/internal/ld/dwarf.go:854 +0x3fc
cmd/link/internal/ld.dwarfgeneratedebugsyms()
/home/boger/golang/upstream/go/src/cmd/link/internal/ld/dwarf.go:1982 +0x930
cmd/link/internal/ld.dodata()
/home/boger/golang/upstream/go/src/cmd/link/internal/ld/data.go:1741 +0x3780
cmd/link/internal/ld.Ldmain()
/home/boger/golang/upstream/go/src/cmd/link/internal/ld/pobj.go:211 +0x1630
cmd/link/internal/ppc64.Main()
/home/boger/golang/upstream/go/src/cmd/link/internal/ppc64/obj.go:45 +0x28
main.main()
/home/boger/golang/upstream/go/src/cmd/link/main.go:36 +0x4c4
The text was updated successfully, but these errors were encountered: