Skip to content
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

misc/cgo: shared libs tests fail on arm64 with segmentation fault [1.10 backport] #24873

Closed
NightTsarina opened this issue Apr 15, 2018 · 8 comments
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge
Milestone

Comments

@NightTsarina
Copy link

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

go version go1.10.1 linux/arm64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="arm64"
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOOS="linux"

What did you do?

##### ../misc/cgo/testshared
--- FAIL: TestTrivialExecutable (4.80s)
	shared_test.go:41: executing ./bin/trivial (trivial executable) failed signal: segmentation fault:
--- FAIL: TestDivisionExecutable (0.81s)
	shared_test.go:41: executing ./bin/division (division executable) failed signal: segmentation fault:
--- FAIL: TestCgoExecutable (1.81s)
	shared_test.go:41: executing ./bin/execgo (cgo executable) failed signal: segmentation fault:
--- FAIL: TestGopathShlib (7.71s)
	shared_test.go:41: executing ./bin/exe (executable linked to GOPATH library) failed signal: segmentation fault:
--- FAIL: TestTwoGopathShlibs (11.75s)
	shared_test.go:41: executing ./bin/exe2 (executable linked to GOPATH library) failed signal: segmentation fault:
--- FAIL: TestThreeGopathShlibs (16.35s)
	shared_test.go:41: executing ./bin/exe3 (executable linked to GOPATH library) failed signal: segmentation fault:
--- FAIL: TestABIChecking (11.67s)
	shared_test.go:860: exe failed, but without line "abi mismatch detected between the executable and libdepBase.so"; got output:
--- FAIL: TestImplicitInclusion (1.65s)
	shared_test.go:41: executing ./bin/implicitcmd (running executable linked against library that contains same package as it) failed signal: segmentation fault:
--- FAIL: TestInterface (2.34s)
	shared_test.go:41: executing ./bin/iface (running type/itab uniqueness tester) failed signal: segmentation fault:
--- FAIL: TestGlobal (1.72s)
	shared_test.go:41: executing ./bin/global (global executable) failed signal: segmentation fault:
FAIL
exit status 1
FAIL	_/home/tincho/golang-1.10-1.10.1/misc/cgo/testshared	105.922s

Building the golang Debian package, misc/cgo/testshared tests fail under arm64 with segmentation fault when trying to execute the test binaries. This is an excerpt from running the tests manually:

BUILD_PATH_PREFIX_MAP='/tmp/go-build=$WORK:' /home/tincho/golang-1.10-1.10.1/pkg/tool/linux_arm64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -installsuffix 5577006791947779410_dynlink -buildmode=exe -buildid=92XVtLk4PlkWixEVRrmR/n3h36TPs9SIEPj3leryp/C0fUIo1GQNMhmBX1v56H/92XVtLk4PlkWixEVRrmR -linkshared -w -extld=gcc $WORK/b001/_pkg_.a
/home/tincho/golang-1.10-1.10.1/pkg/tool/linux_arm64/buildid -w $WORK/b001/exe/a.out # internal
mkdir -p /tmp/testshared261540010/bin/
mv $WORK/b001/exe/a.out /tmp/testshared261540010/bin/exe3
rm -r $WORK/b001/
--- FAIL: TestThreeGopathShlibs (20.88s)
	shared_test.go:41: executing ./bin/exe3 (executable linked to GOPATH library) failed signal: segmentation fault:

Running the binaries under gdb fails immediately without any useful stack trace, seems like a linking issue:

$ gdb /tmp/testshared261540010/bin/exe3
GNU gdb (Debian 7.12-6+b1) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /tmp/testshared261540010/bin/exe3...(no debugging symbols found)...done.
(gdb) n
The program is not being run.
(gdb) start
Temporary breakpoint 1 at 0x400be0
Starting program: /tmp/testshared261540010/bin/exe3 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000ffffb79366e0 in __libc_start_main () from /lib/aarch64-linux-gnu/libc.so.6
#2  0x0000000000400b1c in _start ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
@NightTsarina
Copy link
Author

I forgot to mention, this only started happening in 1.10.1, builds were fine until 1.10: https://buildd.debian.org/status/logs.php?pkg=golang-1.10&arch=arm64

@mwhudson
Copy link
Contributor

https://go-review.googlesource.com/c/go/+/104815 fixed this, I never got around to filing a bug. We could use this bug to track the backporting (or not) to 1.10 though...

@mwhudson
Copy link
Contributor

I forgot to mention, this only started happening in 1.10.1, builds were fine until 1.10: https://buildd.debian.org/status/logs.php?pkg=golang-1.10&arch=arm64

Oh yeah, and it's not a change in Go that caused this to start happening, it's a change in glibc (specifically the crt0.o object that all binaries are linked with)

@andybons andybons changed the title cgo shared libs tests fail on arm64 with segmentation fault misc/cgo: shared libs tests fail on arm64 with segmentation fault Apr 16, 2018
@andybons andybons added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 16, 2018
@andybons andybons added this to the Go1.10.2 milestone Apr 16, 2018
@andybons
Copy link
Member

Adding to 1.10.2 milestone for discussion. @ianlancetaylor

@ianlancetaylor
Copy link
Member

I'm OK with backporting CL 104815 to 1.10.2, to keep up with glibc changes.

@FiloSottile FiloSottile changed the title misc/cgo: shared libs tests fail on arm64 with segmentation fault misc/cgo: shared libs tests fail on arm64 with segmentation fault [1.10 backport] Apr 19, 2018
@FiloSottile FiloSottile added CherryPickApproved Used during the release process for point releases and removed NeedsFix The path to resolution is known, but the work has not been done. labels Apr 19, 2018
@FiloSottile
Copy link
Contributor

@mwhudson can you please mail the cherry-pick per the (new) process at https://github.com/golang/go/wiki/MinorReleases? Thank you!

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/110035 mentions this issue: [release-branch.go1.10] cmd/link: do not pass -no-pie to host linker when -linkshared is passed

gopherbot pushed a commit that referenced this issue Apr 27, 2018
…when -linkshared is passed

As the comment above the code I'm changing says, when building with
-buildmode=exe, the default compiler flags produce code incompatible with PIE.
But when -linkshared is passed, the default compiler flags are not used so this
does not apply. And now I've found a system (linux/arm64 with glibc 2.27) where
this combination of flags causes a problem, albeit for reasons I don't really
understand, so stop passing -no-pie when -linkshared is passed.

Fixes #24873

Change-Id: I412ec7941dc0cb89e6d1b171fc29288aadcb9f20
Reviewed-on: https://go-review.googlesource.com/104815
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 2d26a65)
Reviewed-on: https://go-review.googlesource.com/110035
Run-TryBot: Andrew Bonventre <andybons@golang.org>
@mwhudson
Copy link
Contributor

mwhudson commented Apr 30, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

6 participants