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

runtime: SIGILL in runtime.asmcgocall #18748

Closed
vetinari opened this issue Jan 22, 2017 · 12 comments
Closed

runtime: SIGILL in runtime.asmcgocall #18748

vetinari opened this issue Jan 22, 2017 · 12 comments

Comments

@vetinari
Copy link

Please answer these questions before submitting your issue. Thanks!

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

1.8rc2: Illegal instruction
1.7.4: go version go1.7.4 linux/arm

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

GOARCH="arm"
GOBIN=""
GOEXE=""
GOHOSTARCH="arm"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/hanno/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm"
CC="gcc"
GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build286957571=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"

output above from 1.7.4, 1.8rc2 just gets a SIGILL

What did you do?

Install go binary from https://storage.googleapis.com/golang/go1.8rc2.linux-armv6l.tar.gz on a Raspberry Pi 1 w/ raspbian, upgraded to latest userland.

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 7.11 (wheezy)
Release:        7.11
Codename:       wheezy
$ uname -a
Linux stone-garden-islet 3.10.21+ #604 PREEMPT Mon Dec 2 20:17:09 GMT 2013 armv6l GNU/Linux
$ cat /proc/cpuinfo 
processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 2.00
Features        : swp half thumb fastmult vfp edsp java tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2708
Revision        : 000e
Serial          : 000000003a17768c

What did you expect to see?

The go version output

What did you see instead?

go binary getting a SIGILL

$ gdb --args /usr/local/go/bin/go version
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 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 "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/go-1.8rc2/bin/go...done.
Loading Go Runtime support.
(gdb) b *'runtime.asmcgocall'
Breakpoint 1 at 0x62e54: file /usr/local/go/src/runtime/asm_arm.s, line 514.
(gdb) r
Starting program: /usr/local/go-1.8rc2/bin/go version
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".

Breakpoint 1, runtime.asmcgocall () at /usr/local/go/src/runtime/asm_arm.s:514
514     TEXT ·asmcgocall(SB),NOSPLIT,$0-12
(gdb) info registers
r0             0xbefff744       3204446020
r1             0x108005a0       276825504
r2             0x108262b8       276980408
r3             0x0      0
r4             0x3b5cf0 3890416
r5             0xd0     208
r6             0xb6e3c000       3068379136
r7             0x810    2064
r8             0x400a50 4196944
r9             0x34     52
r10            0x57e828 5761064
r11            0x576a98 5728920
r12            0x0      0
sp             0xbefff728       0xbefff728
lr             0x3fa1c  260636
pc             0x62e54  0x62e54 <runtime.asmcgocall>
cpsr           0x20000010       536870928
(gdb) c
Continuing.

Program received signal SIGILL, Illegal instruction.
0x00011384 in _cgo_try_pthread_create ()
(gdb) info registers
r0             0xbefff5c4       3204445636
r1             0xbefff5cc       3204445644
r2             0x11460  70752
r3             0x592008 5840904
r4             0x0      0
r5             0xbefff5cc       3204445644
r6             0xbefff670       3204445808
r7             0x592008 5840904
r8             0x57ec38 5762104
r9             0x34     52
r10            0x57e828 5761064
r11            0x576a98 5728920
r12            0x108005a0       276825504
sp             0xbefff590       0xbefff590
lr             0x11534  70964
pc             0x11384  0x11384 <_cgo_try_pthread_create+8>
cpsr           0x60000010       1610612752
(gdb) bt
#0  0x00011384 in _cgo_try_pthread_create ()
#1  0x00011534 in _cgo_sys_thread_start ()
#2  0x00062eac in runtime.asmcgocall () at /usr/local/go/src/runtime/asm_arm.s:543
#3  0x003b9430 in type.* ()
#4  0x003b9430 in type.* ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) ^D
$
@vetinari
Copy link
Author

Note: gofmt runs fine, godoc also gets a SIGILL

@josharian
Copy link
Contributor

Possibly related: #18694. cc @minux @cherrymui

@josharian josharian added this to the Go1.8Maybe milestone Jan 22, 2017
@cherrymui
Copy link
Member

I can confirm that, on my Raspberry Pi 1. I wonder whether the release binary is really compiled to ARMv6, especially the C part (since gofmt runs ok, which is a pure Go binary).

@bradfitz
Copy link
Contributor

@cherrymui, can you inspect the binaries from the download URL and check?

Otherwise, you can see how they're built in x/build/cmd/release

/cc @broady

@cherrymui
Copy link
Member

cherrymui commented Jan 22, 2017

@bradfitz, yes, I just tried the binary from https://storage.googleapis.com/golang/go1.8rc2.linux-armv6l.tar.gz, got SIGILL on the go binary and godoc, while gofmt is ok. SIGILL happened in _cgo_try_pthread_create, on an ARMv7 instruction, that's why I wonder that's the C compiler.

@cherrymui
Copy link
Member

It seems cmd/release just runs all.bash on the linux-arm builder, and I didn't see anywhere in the build procedure it sets gcc flags. So I assume it just builds for its native architecture, which is ARMv7.
It seems it has been like that for long. I wonder how it worked before, maybe we are just lucky that it happened to not generate new instructions? FWIW, the fault is in _cgo_try_pthread_create which is new in 1.8 (but the function itself looks ok).

@bradfitz
Copy link
Contributor

Which gcc flags should be set? And by what, ... should cmd/go do it?

@cherrymui
Copy link
Member

I wonder setting GOARM=6 should imply setting gcc flags -march=armv6, maybe by cmd/go?
cc @minux

@minux
Copy link
Member

minux commented Jan 22, 2017 via email

@bradfitz
Copy link
Contributor

@minux, SGTM.

Could you send a CL?

@cherrymui
Copy link
Member

@minux SGTM, if it works.

@cherrymui
Copy link
Member

I send CL https://go-review.googlesource.com/c/35501/. It works on my raspberry pi.

@golang golang locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants