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/dist: binary distribution faults on software fp mismatch #6448

Closed
gopherbot opened this issue Sep 22, 2013 · 24 comments
Closed

cmd/dist: binary distribution faults on software fp mismatch #6448

gopherbot opened this issue Sep 22, 2013 · 24 comments
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 22, 2013

by pj@isomero.us:

1. What is a short input program that triggers the error?
http://play.golang.org/p/c6IGPOs4Ra

2. What is the full compiler output?
<unknown line number>: internal compiler error: fault

3. What version of the compiler are you using?  (Run it with the -V flag.)
5g version devel +5b367120d592 Thu Sep 19 17:12:00 2013 +1000
@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Sep 22, 2013

Comment 1:

Please explain:
- what is the command you are running ?
- how much memory do you have available ?
- what is the system you are running 5g on ?
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 22, 2013

Comment 2 by pj@isomero.us:

- What is the command you are running?
"go build"
- How much memory do you have available?
350 MB RAM free / 512 MB RAM total.
- What is the system you are running 5g on?
BeagleBone Black
@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Sep 22, 2013

Comment 3:

Please run go build -x
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 22, 2013

Comment 4 by pj@isomero.us:

$ go build -x
WORK=/tmp/go-build771135909
mkdir -p $WORK/_/home/root/test/_obj/
cd /home/root/test
/usr/local/go/pkg/tool/linux_arm/5g -o $WORK/_/home/root/test/_obj/_go_.5 -p
_/home/root/test -complete -D _/home/root/test -I $WORK ./list.go
# _/home/root/test
<unknown line number>: internal compiler error: fault
@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Sep 22, 2013

Comment 5:

Does it also happen if you just say:
/usr/local/go/pkg/tool/linux_arm/5g list.go ?
If so, can you run it under gdb and obtain a backtrace ?
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 22, 2013

Comment 6 by pj@isomero.us:

(gdb) run list.go
Starting program: /usr/local/go/pkg/tool/linux_arm/5g list.go
Program received signal SIGSEGV, Segmentation fault.
0xb6f7e364 in frexpl () from /lib/libm.so.6
(gdb) bt
#0  0xb6f7e364 in frexpl () from /lib/libm.so.6
#1  0x00033060 in mpmovecflt (a=a@entry=0xbefff950, c=10)
    at /tmp/bindist030113356/go/src/cmd/gc/mparith3.c:273
#2  0x00030be8 in mpmulcflt (a=a@entry=0x8d1f8, c=<optimized out>)
    at /tmp/bindist030113356/go/src/cmd/gc/mparith1.c:119
#3  0x000311f0 in mpatoflt (a=0x8d1f8, as=as@entry=0x651c8 "33554431p103")
    at /tmp/bindist030113356/go/src/cmd/gc/mparith1.c:375
#4  0x0001eaf8 in typeinit ()
    at /tmp/bindist030113356/go/src/cmd/gc/align.c:576
#5  0x0002f984 in p9main (argc=8, argv=0x8c218)
    at /tmp/bindist030113356/go/src/cmd/gc/lex.c:341
#6  0x00008ef4 in main (argc=<optimized out>, argv=<optimized out>)
    at /tmp/bindist030113356/go/src/lib9/main.c:55
@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Sep 22, 2013

Comment 7:

Can you also say "disas" and "info reg" in addition to backtrace ?
@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Sep 22, 2013

Comment 8:

Also explain: how did you install this version of Go? (from Mercurial? from Go 1.2rc1
binary distribution?) and what is your operating system flavour.
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 22, 2013

Comment 9 by pj@isomero.us:

(gdb) disas
Dump of assembler code for function frexpl:
   0xb6f7e348 <+0>:   movw    r12, #65535 ; 0xffff
   0xb6f7e34c <+4>:   bic r3, r1, #-2147483648    ; 0x80000000
   0xb6f7e350 <+8>:   movt    r12, #32751 ; 0x7fef
   0xb6f7e354 <+12>:  vmov    d16, r0, r1
   0xb6f7e358 <+16>:  cmp r3, r12
   0xb6f7e35c <+20>:  push    {r4}        ; (str r4, [sp, #-4]!)
   0xb6f7e360 <+24>:  mov r4, #0
=> 0xb6f7e364 <+28>:   str r4, [r2]
   0xb6f7e368 <+32>:  bgt 0xb6f7e3b8 <frexpl+112>
   0xb6f7e36c <+36>:  orrs    r12, r3, r0
   0xb6f7e370 <+40>:  beq 0xb6f7e3b8 <frexpl+112>
   0xb6f7e374 <+44>:  cmp r3, #1048576    ; 0x100000
   0xb6f7e378 <+48>:  vldrlt  d17, [pc, #72]  ; 0xb6f7e3c8 <frexpl+128>
   0xb6f7e37c <+52>:  vmullt.f64  d16, d16, d17
   0xb6f7e380 <+56>:  mvnlt   r4, #53 ; 0x35
   0xb6f7e384 <+60>:  vmovlt  r0, r1, d16
   0xb6f7e388 <+64>:  biclt   r3, r1, #-2147483648    ; 0x80000000
   0xb6f7e38c <+68>:  bic r12, r1, #2130706432    ; 0x7f000000
   0xb6f7e390 <+72>:  vmov    r0, r1, d16
   0xb6f7e394 <+76>:  bic r12, r12, #15728640 ; 0xf00000
   0xb6f7e398 <+80>:  orr r12, r12, #1069547520   ; 0x3fc00000
   0xb6f7e39c <+84>:  asr r3, r3, #20
---Type <return> to continue, or q <return> to quit---
   0xb6f7e3a0 <+88>:  orr r1, r12, #2097152   ; 0x200000
   0xb6f7e3a4 <+92>:  sub r3, r3, #1020   ; 0x3fc
   0xb6f7e3a8 <+96>:  sub r3, r3, #2
   0xb6f7e3ac <+100>: add r4, r3, r4
   0xb6f7e3b0 <+104>: str r4, [r2]
   0xb6f7e3b4 <+108>: vmov    d16, r0, r1
   0xb6f7e3b8 <+112>: vmov    r0, r1, d16
   0xb6f7e3bc <+116>: ldmfd   sp!, {r4}
   0xb6f7e3c0 <+120>: bx  lr
   0xb6f7e3c4 <+124>: nop {0}
   0xb6f7e3c8 <+128>: andeq   r0, r0, r0
   0xb6f7e3cc <+132>: cmpmi   r0, #0
End of assembler dump.
(gdb) info reg
r0             0xbefff92c   3204446508
r1             0x0  0
r2             0x0  0
r3             0x0  0
r4             0x0  0
r5             0x0  0
r6             0x8d1f8  578040
r7             0x0  0
r8             0x651c9  414153
r9             0x33 51
r10            0xa  10
r11            0x0  0
r12            0x7fefffff   2146435071
sp             0xbefff924   0xbefff924
lr             0x33060  208992
pc             0xb6f7e364   0xb6f7e364 <frexpl+28>
cpsr           0x80000010   -2147483632
This is with Dave Cheney's ARM tarball: http://dave.cheney.net/unofficial-arm-tarballs
This is on Angstrom (32-bit Linux).
@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Sep 22, 2013

Comment 10:

I think you have a calling convention mismatch. Please show the disasm of the calling
frame.
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 22, 2013

Comment 11 by pj@isomero.us:

Sorry, I'm rather new to gdb. How exactly would I do that?
@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Sep 22, 2013

Comment 12:

Say "up" before saying "disas".
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 22, 2013

Comment 13 by pj@isomero.us:

(gdb) run list.go
Starting program: /usr/local/go/pkg/tool/linux_arm/5g list.go
Program received signal SIGSEGV, Segmentation fault.
0xb6f7e364 in frexpl () from /lib/libm.so.6
(gdb) up
#1  0x00033060 in mpmovecflt (a=a@entry=0xbefff950, c=10)
    at /tmp/bindist030113356/go/src/cmd/gc/mparith3.c:273
273 /tmp/bindist030113356/go/src/cmd/gc/mparith3.c: No such file or directory.
(gdb) disas
Dump of assembler code for function mpmovecflt:
   0x00033008 <+0>:   push    {r4, r5, r6, lr}
   0x0003300c <+4>:   vpush   {d8-d9}
   0x00033010 <+8>:   vmov.f64    d8, d0
   0x00033014 <+12>:  sub sp, sp, #8
   0x00033018 <+16>:  mov r2, #0
   0x0003301c <+20>:  mov r3, #0
   0x00033020 <+24>:  mov r4, r0
   0x00033024 <+28>:  bl  0x327ac <mpmovecfix>
   0x00033028 <+32>:  mov r5, #0
   0x0003302c <+36>:  vcmp.f64    d8, #0.0
   0x00033030 <+40>:  strh    r5, [r4, #68]   ; 0x44
   0x00033034 <+44>:  vmrs    APSR_nzcv, fpscr
   0x00033038 <+48>:  beq 0x330c4 <mpmovecflt+188>
   0x0003303c <+52>:  vcmpe.f64   d8, #0.0
   0x00033040 <+56>:  vmrs    APSR_nzcv, fpscr
   0x00033044 <+60>:  movmi   r3, #1
   0x00033048 <+64>:  vnegmi.f64  d0, d8
   0x0003304c <+68>:  strbmi  r3, [r4, #64]   ; 0x40
   0x00033050 <+72>:  vmovpl.f64  d0, d8
   0x00033054 <+76>:  add r0, sp, #4
   0x00033058 <+80>:  vldr    d9, [pc, #120]  ; 0x330d8 <mpmovecflt+208>
   0x0003305c <+84>:  bl  0x8d5c
---Type <return> to continue, or q <return> to quit---
=> 0x00033060 <+88>:   ldrh    r6, [sp, #4]
   0x00033064 <+92>:  str r5, [sp, #4]
   0x00033068 <+96>:  mov r5, #1
   0x0003306c <+100>: vmov.f64    d8, d0
   0x00033070 <+104>: b   0x3308c <mpmovecflt+132>
   0x00033074 <+108>: bl  0x31950 <mpshiftfix>
   0x00033078 <+112>: str r5, [sp, #4]
   0x0003307c <+116>: add r5, r5, #1
   0x00033080 <+120>: cmp r5, #11
   0x00033084 <+124>: beq 0x330c4 <mpmovecflt+188>
   0x00033088 <+128>: ldrh    r6, [r4, #68]   ; 0x44
   0x0003308c <+132>: vmul.f64    d8, d8, d9
   0x00033090 <+136>: sub r6, r6, #29
   0x00033094 <+140>: vmov.f64    d0, d8
   0x00033098 <+144>: bl  0x8c54
   0x0003309c <+148>: mov r0, r4
   0x000330a0 <+152>: mov r1, #29
   0x000330a4 <+156>: strh    r6, [r4, #68]   ; 0x44
   0x000330a8 <+160>: vcvt.s32.f64    s0, d0
   0x000330ac <+164>: vcvt.f64.s32    d7, s0
   0x000330b0 <+168>: vstr    s0, [r4]
   0x000330b4 <+172>: vsub.f64    d8, d8, d7
   0x000330b8 <+176>: vcmp.f64    d8, #0.0
---Type <return> to continue, or q <return> to quit---
   0x000330bc <+180>: vmrs    APSR_nzcv, fpscr
   0x000330c0 <+184>: bne 0x33074 <mpmovecflt+108>
   0x000330c4 <+188>: mov r0, r4
   0x000330c8 <+192>: add sp, sp, #8
   0x000330cc <+196>: vpop    {d8-d9}
   0x000330d0 <+200>: pop {r4, r5, r6, lr}
   0x000330d4 <+204>: b   0x32aac <mpnorm>
   0x000330d8 <+208>: andeq   r0, r0, r0
   0x000330dc <+212>: bicmi   r0, r0, r0
End of assembler dump.
@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Sep 22, 2013

Comment 14:

I think that your system uses the soft float ABI while Dave's binary is hard-float
(armhf), thus incompatible. I'm not sure how to confirm the hypothesis. 
Try running "readelf -A" on /lib/libm.so.6 and on /usr/local/go/pkg/tool/linux_arm/5g
@davecheney
Copy link
Contributor

@davecheney davecheney commented Sep 22, 2013

Comment 15:

I think Remy is right on the money, you will probably have to compile go on your BBB, it
takes ~45 mins for ./all.bash, less than half of that if you run ./make,bash only.

Labels changed: removed go1.2maybe.

@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 22, 2013

Comment 16 by pj@isomero.us:

That was it :).
Thanks for the help!
@davecheney
Copy link
Contributor

@davecheney davecheney commented Sep 22, 2013

Comment 17:

Thanks for the investigation. I'll add a note to the tarballs page. I don't have the
time to produce yet another permutation (mutliarch/non multiarch is already a bridge to
far). WTH is angstrom not using the hardfloat abi ? The cortex A8 chip can certainly
provide it.

Status changed to Done.

@minux
Copy link
Member

@minux minux commented Sep 22, 2013

Comment 18:

dave, how about statically linking all gcc compiled executables?
i think that will fix the problem.
for the vfp version, compile with hardfloat, and for the nonvfp version, compile with
soft floating point.
@davecheney
Copy link
Contributor

@davecheney davecheney commented Sep 22, 2013

Comment 19:

@minux, that sound like a great idea, but there is a catch. I use the dist tool to build
these tarballs, so that I can say they are produced by the same process as the official
tarballs. 
Is it possible to add this facility to misc/dist or cmd/go ?
@davecheney
Copy link
Contributor

@davecheney davecheney commented Sep 22, 2013

Comment 20:

Ideally, you should install an angstrom distro that supports hard float, it's better,
really. 
I got my BBB a few days ago and it's currently assigned to FreeBSD/arm duties, if I get
time, ill try to research hardfp options for angstrom.
@minux
Copy link
Member

@minux minux commented Sep 23, 2013

Comment 21:

@dave, i think it's too late to propose change to cmd/dist (i think cmd/dist need to
support passing
-static to gcc).
but anyway, let's raise this question on golang-dev.
@rsc
Copy link
Contributor

@rsc rsc commented Sep 23, 2013

Comment 22:

It is fine to make changes to cmd/dist to fix this bug as long as they are as small as
possible.

Labels changed: added priority-soon, go1.2maybe, removed priority-triage.

Status changed to Accepted.

@minux
Copy link
Member

@minux minux commented Sep 25, 2013

Comment 23:

https://golang.org/cl/13887043/

Owner changed to @minux.

Status changed to Started.

@minux
Copy link
Member

@minux minux commented Oct 2, 2013

Comment 24:

This issue was closed by revision 6b188ef.

Status changed to Fixed.

@gopherbot gopherbot added fixed labels Oct 2, 2013
@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.