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

cmd/compile: mipsle: running error SIGILL: illegal instruction #27236

Open
wumao opened this issue Aug 26, 2018 · 11 comments
Open

cmd/compile: mipsle: running error SIGILL: illegal instruction #27236

wumao opened this issue Aug 26, 2018 · 11 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@wumao
Copy link

wumao commented Aug 26, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.11 linux/amd64

Does this issue reproduce with the latest release?

yes

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

build on : amd64 linux,
runing on: Linux OpenWrt 4.4.14 #1 Mon May 29 15:04:41 UTC 2017 mips GNU/Linux

What did you do?

file from:
https://github.com/eclipse/paho.mqtt.golang/tree/master/cmd/simple/main.go
build command:
env GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "-s -w"

runing on openwrt system,32 bit os. router.
MT7620A 16M ROM, 128M RAM

root@OpenWrt:~# ./simple 
SIGILL: illegal instruction
PC=0x13ebac m=0 sigcode=128

goroutine 1 [running, locked to thread]:
math/big.init()
	/usr/local/go/src/math/big/sqrt.go:10 +0xbc fp=0xc22780 sp=0xc22770 pc=0x13ebac
crypto/elliptic.init()
	<autogenerated>:1 +0x88 fp=0xc22784 sp=0xc22780 pc=0x14b150
crypto/ecdsa.init()
	<autogenerated>:1 +0x98 fp=0xc22798 sp=0xc22784 pc=0x15bd60
crypto/tls.init()
	<autogenerated>:1 +0x90 fp=0xc227b4 sp=0xc22798 pc=0x1b0568
github.com/eclipse/paho%2emqtt%2egolang.init()
	<autogenerated>:1 +0xc0 fp=0xc227c8 sp=0xc227b4 pc=0x237eb4
main.init()
	<autogenerated>:1 +0xa0 fp=0xc227cc sp=0xc227c8 pc=0x239400
runtime.main()
	/usr/local/go/src/runtime/proc.go:189 +0x1f8 fp=0xc227ec sp=0xc227cc pc=0x431dc
runtime.goexit()
	/usr/local/go/src/runtime/asm_mipsx.s:660 +0x4 fp=0xc227ec sp=0xc227ec pc=0x76b70

r0   0x0	r1   0x2
r2   0x1	r3   0x1
r4   0x8ece6c	r5   0x1
r6   0x4	r7   0x54
r8   0x27a0e0	r9   0x2f2e46
r10  0x8	r11  0x0
r12  0x51	r13  0x1f
r14  0x1	r15  0x52
r16  0x0	r17  0x80000000
r18  0xff	r19  0x6fa46804
r20  0xc0c288	r21  0xc0c288
r22  0x2c1508	r23  0x2f0000
r24  0x2	r25  0x0
r26  0x0	r27  0x0
r28  0xfffff000	r29  0xc22770
r30  0xc000e0	r31  0x13eba8
pc   0x13ebac	link 0x13eba8
lo   0x0	hi   0x0
@wumao
Copy link
Author

wumao commented Aug 26, 2018

root@vultr:~/server# vim http_server.go 

package main
import (
            "net/http"
)
func main() {
     http.Handle("/", http.FileServer(http.Dir("./")))
     http.ListenAndServe(":8080", nil)
}
root@OpenWrt:~# ./server 
SIGILL: illegal instruction
PC=0xfbe08 m=0 sigcode=128

goroutine 1 [running, locked to thread]:
math/big.init()
	/usr/local/go/src/math/big/sqrt.go:10 +0xbc fp=0xc226c8 sp=0xc226b8 pc=0xfbe08
crypto/elliptic.init()
	<autogenerated>:1 +0x88 fp=0xc226cc sp=0xc226c8 pc=0x108510
crypto/ecdsa.init()
	<autogenerated>:1 +0x98 fp=0xc226e0 sp=0xc226cc pc=0x119284
crypto/tls.init()
	<autogenerated>:1 +0x90 fp=0xc226fc sp=0xc226e0 pc=0x1ab230
net/http.init()
	<autogenerated>:1 +0x84 fp=0xc227c8 sp=0xc226fc pc=0x2342a4
main.init()
	<autogenerated>:1 +0x80 fp=0xc227cc sp=0xc227c8 pc=0x2433c0
runtime.main()
	/usr/local/go/src/runtime/proc.go:189 +0x1f8 fp=0xc227ec sp=0xc227cc pc=0x4329c
runtime.goexit()
	/usr/local/go/src/runtime/asm_mipsx.s:660 +0x4 fp=0xc227ec sp=0xc227ec pc=0x76d28

r0   0x0	r1   0x2
r2   0x1	r3   0x20
r4   0x8fdb5c	r5   0x1
r6   0x10	r7   0x20
r8   0x4	r9   0x0
r10  0x20	r11  0x0
r12  0x1	r13  0x0
r14  0x3082c7	r15  0x3082c8
r16  0x0	r17  0x0
r18  0x8	r19  0x0
r20  0x6f29e038	r21  0xc38100
r22  0xc22620	r23  0x310000
r24  0x287820	r25  0x0
r26  0x0	r27  0x0
r28  0x0	r29  0xc226b8
r30  0xc000e0	r31  0xfbe04
pc   0xfbe08	link 0xfbe04
lo   0x0	hi   0x0

@ALTree
Copy link
Member

ALTree commented Aug 26, 2018

Did this work on go1.10?

@ALTree ALTree changed the title go 1.11 mipsel 32: running error SIGILL: illegal instruction cmd/compile: mipsle: running error SIGILL: illegal instruction on go1.11 Aug 26, 2018
@ALTree ALTree added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 26, 2018
@wumao
Copy link
Author

wumao commented Aug 26, 2018

no, use go 1.10.3
env GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "-s -w"
root@OpenWrt:/tmp# ./server
Illegal instruction

@ALTree ALTree added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Aug 26, 2018
@ALTree ALTree added this to the Go1.12 milestone Aug 26, 2018
@ALTree ALTree changed the title cmd/compile: mipsle: running error SIGILL: illegal instruction on go1.11 cmd/compile: mipsle: running error SIGILL: illegal instruction Aug 26, 2018
@ianlancetaylor
Copy link
Contributor

Can you use gdb to disassemble the PC address shown in the error, so we can see what the illegal instruction is? Thanks.

@cherrymui
Copy link
Member

I cannot reproduce the exactly same binary, but I took your http_server.go and compiled with Go 1.11, at math/big.init + 0xbc I see lui $1,0x3fe0, which is a legal instruction on mipsle softfloat. I'm not sure what's happening.

@wumao
Copy link
Author

wumao commented Aug 26, 2018

(gdb) disassemble 0xfbe08
Dump of assembler code for function math/big.init:
0x000fbd4c <+0>: lw at,8(s8)
0x000fbd50 <+4>: sltu at,at,sp
0x000fbd54 <+8>: bnez at,0xfbd70 <math/big.init+36>
0x000fbd58 <+12>: nop
0x000fbd5c <+16>: move v1,ra
0x000fbd60 <+20>: jal 0x74af0 <runtime.morestack_noctxt>
0x000fbd64 <+24>: nop
0x000fbd68 <+28>: b 0xfbd4c <math/big.init>
0x000fbd6c <+32>: nop
0x000fbd70 <+36>: sw ra,-16(sp)
0x000fbd74 <+40>: addiu sp,sp,-16
0x000fbd78 <+44>: lui s7,0x49
0x000fbd7c <+48>: lbu at,12716(s7)
0x000fbd80 <+52>: li v0,1
0x000fbd84 <+56>: sltu v0,v0,at
0x000fbd88 <+60>: beqz v0,0xfbda0 <math/big.init+84>
0x000fbd8c <+64>: nop
0x000fbd90 <+68>: lw ra,0(sp)
0x000fbd94 <+72>: addiu sp,sp,16
0x000fbd98 <+76>: jr ra
0x000fbd9c <+80>: nop
0x000fbda0 <+84>: xori at,at,0x1
0x000fbda4 <+88>: bnez at,0xfbdb8 <math/big.init+108>
0x000fbda8 <+92>: nop
0x000fbdac <+96>: jal 0x3fb2c <runtime.throwinit>
0x000fbdb0 <+100>: nop
0x000fbdb4 <+104>: teq zero,zero
0x000fbdb8 <+108>: li at,1
0x000fbdbc <+112>: lui s7,0x49
0x000fbdc0 <+116>: sb at,12716(s7)
0x000fbdc4 <+120>: jal 0x87108 <strconv.init>
0x000fbdc8 <+124>: nop
0x000fbdcc <+128>: jal 0xdd5dc <fmt.init>
0x000fbdd0 <+132>: nop
0x000fbdd4 <+136>: jal 0x8cf84 <io.init>
0x000fbdd8 <+140>: nop
0x000fbddc <+144>: jal 0xe563c <strings.init>
0x000fbde0 <+148>: nop
0x000fbde4 <+152>: jal 0xe5a24 <encoding/binary.init>
---Type to continue, or q to quit---
0x000fbde8 <+156>: nop
0x000fbdec <+160>: jal 0xe8ad4 <bytes.init>
0x000fbdf0 <+164>: nop
0x000fbdf4 <+168>: jal 0xe9b4c <math/rand.init>
0x000fbdf8 <+172>: nop
0x000fbdfc <+176>: jal 0x8b024 <sync.init>
0x000fbe00 <+180>: nop
0x000fbe04 <+184>: lui s7,0x31
0x000fbe08 <+188>: lwc1 $f0,-24480(s7)
0x000fbe0c <+192>: lui s7,0x31
0x000fbe10 <+196>: lwc1 $f1,-24476(s7)
0x000fbe14 <+200>: swc1 $f0,4(sp)
0x000fbe18 <+204>: swc1 $f1,8(sp)
0x000fbe1c <+208>: jal 0xebcf4 <math/big.NewFloat>
0x000fbe20 <+212>: nop
0x000fbe24 <+216>: lw s5,12(sp)
0x000fbe28 <+220>: lui s7,0x49
0x000fbe2c <+224>: lw at,13424(s7)
0x000fbe30 <+228>: bnez at,0xfbf04 <math/big.init+440>
0x000fbe34 <+232>: nop
0x000fbe38 <+236>: lui s7,0x48
0x000fbe3c <+240>: sw s5,8888(s7)
0x000fbe40 <+244>: lui s7,0x31
0x000fbe44 <+248>: lwc1 $f0,-24464(s7)
0x000fbe48 <+252>: lui s7,0x31
0x000fbe4c <+256>: lwc1 $f1,-24460(s7)
0x000fbe50 <+260>: swc1 $f0,4(sp)
0x000fbe54 <+264>: swc1 $f1,8(sp)
0x000fbe58 <+268>: jal 0xebcf4 <math/big.NewFloat>
0x000fbe5c <+272>: nop
0x000fbe60 <+276>: lw s5,12(sp)
0x000fbe64 <+280>: lui s7,0x49
0x000fbe68 <+284>: lw at,13424(s7)
0x000fbe6c <+288>: bnez at,0xfbeec <math/big.init+416>
0x000fbe70 <+292>: nop
0x000fbe74 <+296>: lui s7,0x48
0x000fbe78 <+300>: sw s5,8896(s7)
0x000fbe7c <+304>: lui s7,0x31
0x000fbe80 <+308>: lwc1 $f0,-24456(s7)
0x000fbe84 <+312>: lui s7,0x31
---Type to continue, or q to quit---
0x000fbe88 <+316>: lwc1 $f1,-24452(s7)
0x000fbe8c <+320>: swc1 $f0,4(sp)
0x000fbe90 <+324>: swc1 $f1,8(sp)
0x000fbe94 <+328>: jal 0xebcf4 <math/big.NewFloat>
0x000fbe98 <+332>: nop
0x000fbe9c <+336>: lw s5,12(sp)
0x000fbea0 <+340>: lui s7,0x49
0x000fbea4 <+344>: lw at,13424(s7)
0x000fbea8 <+348>: bnez at,0xfbed4 <math/big.init+392>
0x000fbeac <+352>: nop
0x000fbeb0 <+356>: lui s7,0x48
0x000fbeb4 <+360>: sw s5,8892(s7)
0x000fbeb8 <+364>: li at,2
0x000fbebc <+368>: lui s7,0x49
0x000fbec0 <+372>: sb at,12716(s7)
0x000fbec4 <+376>: lw ra,0(sp)
0x000fbec8 <+380>: addiu sp,sp,16
0x000fbecc <+384>: jr ra
0x000fbed0 <+388>: nop
0x000fbed4 <+392>: lui s4,0x48
0x000fbed8 <+396>: addiu s4,s4,8892
0x000fbedc <+400>: jal 0x76d44 <runtime.gcWriteBarrier>
0x000fbee0 <+404>: nop
0x000fbee4 <+408>: b 0xfbeb8 <math/big.init+364>
0x000fbee8 <+412>: nop
0x000fbeec <+416>: lui s4,0x48
0x000fbef0 <+420>: addiu s4,s4,8896
0x000fbef4 <+424>: jal 0x76d44 <runtime.gcWriteBarrier>
0x000fbef8 <+428>: nop
0x000fbefc <+432>: b 0xfbe7c <math/big.init+304>
0x000fbf00 <+436>: nop
0x000fbf04 <+440>: lui s4,0x48
0x000fbf08 <+444>: addiu s4,s4,8888
0x000fbf0c <+448>: jal 0x76d44 <runtime.gcWriteBarrier>
0x000fbf10 <+452>: nop
0x000fbf14 <+456>: b 0xfbe40 <math/big.init+244>
0x000fbf18 <+460>: nop
End of assembler dump.
(gdb)

@cherrymui
Copy link
Member

0x000fbe08 <+188>: lwc1 $f0,-24480(s7)

This is a floating point instruction. Probably for some reason your softfloat setting didn't go through. Maybe you have installed the standard library compiled with hardfloat. Try

GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -a

using -a to force a complete rebuild, and see if this solves the problem.

@bradfitz
Copy link
Contributor

Is GOMIPS=softfloat not part of the build ID cache key?

@ianlancetaylor
Copy link
Contributor

From reading the code there may be a bug here: it looks like if GOARCH is mipsle, the build ID will include the value of the environment variable GOMIPSLE, which is not correct.

@ianlancetaylor
Copy link
Contributor

Filed #27260 for the GOMIPS problem.

@gopherbot
Copy link

Change https://golang.org/cl/131378 mentions this issue: cmd/go/internal/work: fix missing GOMIPS{,64} to ActionID on little endian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

8 participants