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: panic: runtime error: floating point error when building on FreeBSD armv6 on RPi-B #39816

Open
seasox opened this issue Jun 24, 2020 · 9 comments
Milestone

Comments

@seasox
Copy link

@seasox seasox commented Jun 24, 2020

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

go1.4 bootstrap

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ /usr/local/go14/bin/go env
GOARCH="arm"
GOBIN=""
GOCHAR="5"
GOEXE=""
GOHOSTARCH="arm"
GOHOSTOS="freebsd"
GOOS="freebsd"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go14"
GOTOOLDIR="/usr/local/go14/pkg/tool/freebsd_arm"
CC="clang"
GOGCCFLAGS="-fPIC -marm -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0"
CXX="clang++"
CGO_ENABLED="0"
$ 

What did you do?

I tried to build go1.14.4

What did you expect to see?

A successful build of go1.14.4

What did you see instead?

Build fails with SIGFPE. The output below comes from a build from FreeBSD ports. Building from source directly (using go1-4 bootstrap) results in the same error.

root@rpi-b:/usr/ports/lang/go # make -DBATCH
===>  License BSD3CLAUSE accepted by the user
===>   go-1.14.4,1 depends on file: /usr/local/sbin/pkg - found
=> go1.14.4.src.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch https://golang.org/dl/go1.14.4.src.tar.gz
go1.14.4.src.tar.gz                                     21 MB 1695 kBps    13s
=> go-freebsd-arm6-go1.14.tar.xz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch https://github.com/dmgk/go-bootstrap/releases/download/go1.14/go-freebsd-arm6-go1.14.tar.xz
go-freebsd-arm6-go1.14.tar.xz                           33 MB 1472 kBps    24s
===> Fetching all distfiles required by go-1.14.4,1 for building
===>  Extracting for go-1.14.4,1
=> SHA256 Checksum OK for go1.14.4.src.tar.gz.
=> SHA256 Checksum OK for go-freebsd-arm6-go1.14.tar.xz.
===>  Patching for go-1.14.4,1
===>  Applying FreeBSD patches for go-1.14.4,1 from /usr/ports/lang/go/files
===>  Configuring for go-1.14.4,1
===>  Building for go-1.14.4,1
cd /usr/ports/lang/go/work/go/src ; /usr/bin/env  XDG_CACHE_HOME=/usr/ports/lang/go/work  GOROOT_BOOTSTRAP=/usr/ports/lang/go/work/go-freebsd-arm6-bootstrap  GOROOT=/usr/ports/lang/go/work/go  GOROOT_FINAL=/usr/local/go  GOBIN=  GOOS=freebsd  GOARCH=arm  GO386=  GOARM=6  /bin/sh make.bash -v
-ap: not found
go: not found
Building Go cmd/dist using /usr/ports/lang/go/work/go-freebsd-arm6-bootstrap. (go1.14 freebsd/arm)
cmd/dist

Building Go toolchain1 using /usr/ports/lang/go/work/go-freebsd-arm6-bootstrap.
math/bits
math
# math
panic: runtime error: floating point error
[signal SIGFPE: floating-point exception code=0x0 addr=0x8317bc pc=0x8317bc]

goroutine 1 [running]:
math.IsInf(...)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/math/bits.go:51
cmd/compile/internal/gc.(*Mpflt).Float64(0x318805e0, 0x200, 0x318df5e0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/mpfloat.go:139 +0x30
cmd/compile/internal/gc.truncfltlit(0x318805e0, 0x31440e40, 0x9c4af0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/const.go:168 +0x90
cmd/compile/internal/gc.convertVal(0x9c4af0, 0x318805e0, 0x31440e40, 0x0, 0x9c4af0, 0x318df5c0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/const.go:398 +0xb8
cmd/compile/internal/gc.convlit1(0x318880a0, 0x31440e40, 0x0, 0x3177540c, 0x318e6301)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/const.go:272 +0x248
cmd/compile/internal/gc.assignconvfn(0x318880a0, 0x31440e40, 0x3177540c, 0x318e6320)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/subr.go:805 +0x74
cmd/compile/internal/gc.assignconv(0x318880a0, 0x31440e40, 0x9e1072, 0xd, 0x318e6320)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/subr.go:792 +0x5c
cmd/compile/internal/gc.typecheckarraylit(0x31440e40, 0xffffffff, 0xffffffff, 0x31760d50, 0xb, 0xb, 0x9e1072, 0xd, 0xa, 0x0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/typecheck.go:2999 +0x180
cmd/compile/internal/gc.typecheckcomplit(0x3187fc20, 0x0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/typecheck.go:2785 +0x1cc0
cmd/compile/internal/gc.typecheck1(0x3187fc20, 0x12, 0x0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/typecheck.go:860 +0x3cf4
cmd/compile/internal/gc.typecheck(0x3187fc20, 0x12, 0x0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/typecheck.go:300 +0x640
cmd/compile/internal/gc.typecheckas(0x318880f0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/typecheck.go:3172 +0x94
cmd/compile/internal/gc.typecheck1(0x318880f0, 0x1, 0x0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/typecheck.go:1900 +0x29b8
cmd/compile/internal/gc.typecheck(0x318880f0, 0x1, 0x0)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/typecheck.go:300 +0x640
cmd/compile/internal/gc.Main(0xa00d70)
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/internal/gc/main.go:580 +0x2d18
main.main()
        /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/src/cmd/compile/main.go:52 +0x98
bootstrap/sort
bootstrap/math/bits
bootstrap/container/heap
bootstrap/internal/goversion
bootstrap/internal/race
go tool dist: FAILED: /usr/ports/lang/go/work/go-freebsd-arm6-bootstrap/bin/go install -gcflags=-l -tags=math_big_pure_go compiler_bootstrap -v bootstrap/cmd/...: exit status 2
*** Error code 2

Stop.
make: stopped in /usr/ports/lang/go
@randall77
Copy link
Contributor

@randall77 randall77 commented Jun 24, 2020

Weird. That chip should have hard float support.

  • Can you run a C program that does floating-point operations (and, particularly, comparisons against the infinities)?
  • Can you find out what the instruction is? The one at 0x8317bc in the bootstrap compiler (in /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/pkg/tool/linux_arm/compile, I think).
  • Try rebuilding with GOARM=5 to get soft floating-point support and see if that fixes anything. You'll probably also need a GOARM=5 bootstrap installation.

A few other, lower priority things to try if you have the time:

  • Can you try 1.15beta1?
  • Can you try bootstrapping with a later Go release, e.g. 1.13.12.
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 25, 2020

Change https://golang.org/cl/239999 mentions this issue: runtime: print faulting instruction on a SIGFPE

@seasox
Copy link
Author

@seasox seasox commented Jun 25, 2020

Hi @randall77!

* Can you run a C program that does floating-point operations (and, particularly, comparisons against the infinities)?

I wrote a simple C program which does some simple float calculation and comparison against +-Infinity from math.h. Works as expected.

* Can you find out what the instruction is? The one at 0x8317bc in the bootstrap compiler (in /home/dg/golang/go-bootstrap/go-freebsd-arm6-bootstrap/pkg/tool/linux_arm/compile, I think).

The instruction seems to be fmstat if I'm not mistaken. I'm not that used to disassembling.

0083178c <cmd/compile/internal/gc.(*Mpflt).Float64>:
  83178c:       e59a1008        ldr     r1, [sl, #8]
  831790:       e15d0001        cmp     sp, r1
  831794:       9a000028        bls     83183c <cmd/compile/internal/gc.(*Mpflt).Float64+0xb0>
  831798:       e52de020        str     lr, [sp, #-32]!
  83179c:       e59d0024        ldr     r0, [sp, #36]
  8317a0:       e1d0b0d0        ldrsb   fp, [r0]
  8317a4:       e58d0004        str     r0, [sp, #4]
  8317a8:       ebe3e80f        bl      12b7ec <math/big.(*Float).Float64>
  8317ac:       ed9d0b02        vldr    d0, [sp, #8]
  8317b0:       e59fb094        ldr     fp, [pc, #148]  ; 83184c <cmd/compile/internal/gc.(*Mpflt).Float64+0xc0>
  8317b4:       ed9b1b00        vldr    d1, [fp]
  8317b8:       eeb40bc1        fcmped  d0, d1
  8317bc:       eef1fa10        fmstat
  8317c0:       da000017        ble     831824 <cmd/compile/internal/gc.(*Mpflt).Float64+0x98>
  8317c4:       e59fb084        ldr     fp, [pc, #132]  ; 831850 <cmd/compile/internal/gc.(*Mpflt).Float64+0xc4>
  8317c8:       e59b0000        ldr     r0, [fp]
  8317cc:       e59fb080        ldr     fp, [pc, #128]  ; 831854 <cmd/compile/internal/gc.(*Mpflt).Float64+0xc8>
* Try rebuilding with GOARM=5 to get soft floating-point support and see if that fixes anything. You'll probably also need a GOARM=5 bootstrap installation.

A few other, lower priority things to try if you have the time:

* Can you try 1.15beta1?

Will do and give another update.

* Can you try bootstrapping with a later Go release, e.g. 1.13.12.

I tried with 1.14 from http://github.com/dmgk/go-bootstrap (default bootstrap on FreeBSD ports) too with the same error. The disassembly above is from 1.14.

root@rpi-b:~jb # /usr/ports/lang/go/work/go-freebsd-arm6-bootstrap/bin/go version
go version go1.14 freebsd/arm

@randall77
Copy link
Contributor

@randall77 randall77 commented Jun 26, 2020

I can't get a freebsd/arm machine at the moment but on linux/arm I see this:

00813c7c <cmd/compile/internal/gc.(*Mpflt).Float64>:
  813c7c:	e59a1008 	ldr	r1, [sl, #8]
  813c80:	e15d0001 	cmp	sp, r1
  813c84:	9a000028 	bls	813d2c <cmd/compile/internal/gc.(*Mpflt).Float64+0xb0>
  813c88:	e52de020 	str	lr, [sp, #-32]!	; 0xffffffe0
  813c8c:	e59d0024 	ldr	r0, [sp, #36]	; 0x24
  813c90:	e1d0b0d0 	ldrsb	fp, [r0]
  813c94:	e58d0004 	str	r0, [sp, #4]
  813c98:	ebe45ed8 	bl	12b800 <math/big.(*Float).Float64>
  813c9c:	ed9d0b02 	vldr	d0, [sp, #8]
  813ca0:	e59fb094 	ldr	fp, [pc, #148]	; 813d3c <cmd/compile/internal/gc.(*Mpflt).Float64+0xc0>
  813ca4:	ed9b1b00 	vldr	d1, [fp]
  813ca8:	eeb40bc1 	vcmpe.f64	d0, d1
  813cac:	eef1fa10 	vmrs	APSR_nzcv, fpscr
  813cb0:	da000017 	ble	813d14 <cmd/compile/internal/gc.(*Mpflt).Float64+0x98>
  813cb4:	e59fb084 	ldr	fp, [pc, #132]	; 813d40 <cmd/compile/internal/gc.(*Mpflt).Float64+0xc4>
  813cb8:	e59b0000 	ldr	r0, [fp]
  813cbc:	e59fb080 	ldr	fp, [pc, #128]	; 813d44 <cmd/compile/internal/gc.(*Mpflt).Float64+0xc8>

It's the same instructions, but it disassembles differently.
That instruction (what your disassembler calls fmstat, the linux/arm disassembler calls vmrs) is fine, we use it all the time. If floating point were really not working, I would expect one of the previous instructions (the vcmpe.f64, aka fcmped, or one of the float loads) to fail.
So I have no idea what is going on here. My only guess is that fmstat/vmrs is not implemented by the chip. Instead, it traps to the OS for the OS to simulate it. Your freebsd installation has a bug where it can't simulate that instruction or has a bug in that simulation.
Try upgrading the OS. The fact that your disassembly is different makes me think it might be an old binutils install, which might mean an old distribution, which might mean an old OS.

@randall77
Copy link
Contributor

@randall77 randall77 commented Jun 26, 2020

Could you post your C code test and the disassembly of it?

@cagedmantis cagedmantis changed the title panic: runtime error: floating point error when building on FreeBSD armv6 on RPi-B cmd/compile: panic: runtime error: floating point error when building on FreeBSD armv6 on RPi-B Jun 26, 2020
@cagedmantis cagedmantis added this to the Backlog milestone Jun 26, 2020
@seasox
Copy link
Author

@seasox seasox commented Jun 27, 2020

I've tried some things in the last few days, including compiling with GOARM=5, which seems to work just fine. I've also upgraded my system to FreeBSD 13-CURRENT from 2020-06-25, which produces the same error when compiling with GOARM=6.

The C test code I wrote is:

#include <math.h>

int main(void) {
        double f = 0.432f;
        double g = 0.742f;

        int i = f > INFINITY;
        int j = g > -INFINITY;
        double h = g - f;

        return 0;
}

Compiled with -O0, the full disassembly made with objdump from binutils-2.33.1_2,1 on FreeBSD 13-CURRENT is:

a.out:     file format elf32-littlearm


Disassembly of section .text:

00011430 <__start>:
   11430:       e92d4800        push    {fp, lr}
   11434:       e1a0b00d        mov     fp, sp
   11438:       e1a06000        mov     r6, r0
   1143c:       e59f0094        ldr     r0, [pc, #148]  ; 114d8 <__start+0xa8>
   11440:       e1a05001        mov     r5, r1
   11444:       e1a04002        mov     r4, r2
   11448:       e5901000        ldr     r1, [r0]
   1144c:       e3510000        cmp     r1, #0, 0
   11450:       05804000        streq   r4, [r0]
   11454:       e3560001        cmp     r6, #1, 0
   11458:       ba000002        blt     11468 <__start+0x38>
   1145c:       e5951000        ldr     r1, [r5]
   11460:       e3510000        cmp     r1, #0, 0
   11464:       1a000012        bne     114b4 <__start+0x84>
   11468:       e3530000        cmp     r3, #0, 0
   1146c:       159f006c        ldrne   r0, [pc, #108]  ; 114e0 <__start+0xb0>
   11470:       15803000        strne   r3, [r0]
   11474:       e59f0068        ldr     r0, [pc, #104]  ; 114e4 <__start+0xb4>
   11478:       e3500000        cmp     r0, #0, 0
   1147c:       0a000002        beq     1148c <__start+0x5c>
   11480:       e59b000c        ldr     r0, [fp, #12]
   11484:       eb0000c5        bl      117a0 <_fini+0x40>
   11488:       ea000000        b       11490 <__start+0x60>
   1148c:       eb0000c7        bl      117b0 <_fini+0x50>
   11490:       e1a00006        mov     r0, r6
   11494:       e1a01005        mov     r1, r5
   11498:       e1a02004        mov     r2, r4
   1149c:       eb000011        bl      114e8 <handle_static_init>
   114a0:       e1a00006        mov     r0, r6
   114a4:       e1a01005        mov     r1, r5
   114a8:       e1a02004        mov     r2, r4
   114ac:       eb00007d        bl      116a8 <main>
   114b0:       eb0000c2        bl      117c0 <_fini+0x60>
   114b4:       e59f0020        ldr     r0, [pc, #32]   ; 114dc <__start+0xac>
   114b8:       e5801000        str     r1, [r0]
   114bc:       e2811001        add     r1, r1, #1, 0
   114c0:       e5512001        ldrb    r2, [r1, #-1]
   114c4:       e3520000        cmp     r2, #0, 0
   114c8:       0affffe6        beq     11468 <__start+0x38>
   114cc:       e352002f        cmp     r2, #47, 0      ; 0x2f
   114d0:       05801000        streq   r1, [r0]
   114d4:       eafffff8        b       114bc <__start+0x8c>
   114d8:       000138b4        .word   0x000138b4
   114dc:       00013890        .word   0x00013890
   114e0:       000138b0        .word   0x000138b0
   114e4:       000127e8        .word   0x000127e8

000114e8 <handle_static_init>:
   114e8:       e92d4ff0        push    {r4, r5, r6, r7, r8, r9, sl, fp, lr}
   114ec:       e28db01c        add     fp, sp, #28, 0
   114f0:       e24dd004        sub     sp, sp, #4, 0
   114f4:       e1a06000        mov     r6, r0
   114f8:       e59f00c4        ldr     r0, [pc, #196]  ; 115c4 <handle_static_init+0xdc>
   114fc:       e3500000        cmp     r0, #0, 0
   11500:       1a00002d        bne     115bc <handle_static_init+0xd4>
   11504:       e59f00bc        ldr     r0, [pc, #188]  ; 115c8 <handle_static_init+0xe0>
   11508:       e1a0a002        mov     sl, r2
   1150c:       e1a05001        mov     r5, r1
   11510:       eb0000a2        bl      117a0 <_fini+0x40>
   11514:       e59f90b0        ldr     r9, [pc, #176]  ; 115cc <handle_static_init+0xe4>
   11518:       e59f00b0        ldr     r0, [pc, #176]  ; 115d0 <handle_static_init+0xe8>
   1151c:       e3a08000        mov     r8, #0, 0
   11520:       e0400009        sub     r0, r0, r9
   11524:       e1a01fc0        asr     r1, r0, #31
   11528:       e0807f21        add     r7, r0, r1, lsr #30
   1152c:       e1580147        cmp     r8, r7, asr #2
   11530:       0a00000c        beq     11568 <handle_static_init+0x80>
   11534:       e3a04000        mov     r4, #0, 0
   11538:       ea000002        b       11548 <handle_static_init+0x60>
   1153c:       e2844001        add     r4, r4, #1, 0
   11540:       e1540147        cmp     r4, r7, asr #2
   11544:       2a000007        bcs     11568 <handle_static_init+0x80>
   11548:       e7993104        ldr     r3, [r9, r4, lsl #2]
   1154c:       e3530002        cmp     r3, #2, 0
   11550:       3afffff9        bcc     1153c <handle_static_init+0x54>
   11554:       e1a00006        mov     r0, r6
   11558:       e1a01005        mov     r1, r5
   1155c:       e1a0200a        mov     r2, sl
   11560:       e12fff33        blx     r3
   11564:       eafffff4        b       1153c <handle_static_init+0x54>
   11568:       e59f9064        ldr     r9, [pc, #100]  ; 115d4 <handle_static_init+0xec>
   1156c:       e59f0064        ldr     r0, [pc, #100]  ; 115d8 <handle_static_init+0xf0>
   11570:       e0400009        sub     r0, r0, r9
   11574:       e1a01fc0        asr     r1, r0, #31
   11578:       e0807f21        add     r7, r0, r1, lsr #30
   1157c:       eb00006f        bl      11740 <_init>
   11580:       e1580147        cmp     r8, r7, asr #2
   11584:       0a00000c        beq     115bc <handle_static_init+0xd4>
   11588:       e3a04000        mov     r4, #0, 0
   1158c:       ea000002        b       1159c <handle_static_init+0xb4>
   11590:       e2844001        add     r4, r4, #1, 0
   11594:       e1540147        cmp     r4, r7, asr #2
   11598:       2a000007        bcs     115bc <handle_static_init+0xd4>
   1159c:       e7993104        ldr     r3, [r9, r4, lsl #2]
   115a0:       e3530002        cmp     r3, #2, 0
   115a4:       3afffff9        bcc     11590 <handle_static_init+0xa8>
   115a8:       e1a00006        mov     r0, r6
   115ac:       e1a01005        mov     r1, r5
   115b0:       e1a0200a        mov     r2, sl
   115b4:       e12fff33        blx     r3
   115b8:       eafffff4        b       11590 <handle_static_init+0xa8>
   115bc:       e24bd01c        sub     sp, fp, #28, 0
   115c0:       e8bd8ff0        pop     {r4, r5, r6, r7, r8, r9, sl, fp, pc}
   115c4:       000127e8        .word   0x000127e8
   115c8:       000115dc        .word   0x000115dc
   115cc:       00011430        .word   0x00011430
   115d0:       00011430        .word   0x00011430
   115d4:       000127e4        .word   0x000127e4
   115d8:       000127e8        .word   0x000127e8

000115dc <finalizer>:
   115dc:       e92d4830        push    {r4, r5, fp, lr}
   115e0:       e28db008        add     fp, sp, #8, 0
   115e4:       e59f404c        ldr     r4, [pc, #76]   ; 11638 <finalizer+0x5c>
   115e8:       e59f004c        ldr     r0, [pc, #76]   ; 1163c <finalizer+0x60>
   115ec:       e0400004        sub     r0, r0, r4
   115f0:       e1a01fc0        asr     r1, r0, #31
   115f4:       e0800f21        add     r0, r0, r1, lsr #30
   115f8:       e3a01000        mov     r1, #0, 0
   115fc:       e1510140        cmp     r1, r0, asr #2
   11600:       1a000001        bne     1160c <finalizer+0x30>
   11604:       e8bd4830        pop     {r4, r5, fp, lr}
   11608:       ea000054        b       11760 <_fini>
   1160c:       e1a05140        asr     r5, r0, #2
   11610:       ea000001        b       1161c <finalizer+0x40>
   11614:       e3550000        cmp     r5, #0, 0
   11618:       0afffff9        beq     11604 <finalizer+0x28>
   1161c:       e0840105        add     r0, r4, r5, lsl #2
   11620:       e2455001        sub     r5, r5, #1, 0
   11624:       e5100004        ldr     r0, [r0, #-4]
   11628:       e3500002        cmp     r0, #2, 0
   1162c:       3afffff8        bcc     11614 <finalizer+0x38>
   11630:       e12fff30        blx     r0
   11634:       eafffff6        b       11614 <finalizer+0x38>
   11638:       00011430        .word   0x00011430
   1163c:       00011430        .word   0x00011430

00011640 <_start>:
   11640:       e1a05002        mov     r5, r2
   11644:       e1a04001        mov     r4, r1
   11648:       e1a03000        mov     r3, r0
   1164c:       e59d0000        ldr     r0, [sp]
   11650:       e28d1004        add     r1, sp, #4, 0
   11654:       e0812100        add     r2, r1, r0, lsl #2
   11658:       e2822004        add     r2, r2, #4, 0
   1165c:       e3cdd007        bic     sp, sp, #7, 0
   11660:       e24dd008        sub     sp, sp, #8, 0
   11664:       e58d5004        str     r5, [sp, #4]
   11668:       e58d4000        str     r4, [sp]
   1166c:       eaffff6f        b       11430 <__start>

00011670 <register_classes>:
   11670:       e92d4800        push    {fp, lr}
   11674:       e1a0b00d        mov     fp, sp
   11678:       e59f0020        ldr     r0, [pc, #32]   ; 116a0 <register_classes+0x30>
   1167c:       e3500000        cmp     r0, #0, 0
   11680:       08bd8800        popeq   {fp, pc}
   11684:       e59f0018        ldr     r0, [pc, #24]   ; 116a4 <register_classes+0x34>
   11688:       e5900000        ldr     r0, [r0]
   1168c:       e3500000        cmp     r0, #0, 0
   11690:       0a000001        beq     1169c <register_classes+0x2c>
   11694:       e59f0008        ldr     r0, [pc, #8]    ; 116a4 <register_classes+0x34>
   11698:       eb00004c        bl      117d0 <_fini+0x70>
   1169c:       e8bd8800        pop     {fp, pc}
   116a0:       00000000        .word   0x00000000
   116a4:       000127e0        .word   0x000127e0

000116a8 <main>:
   116a8:       e24dd028        sub     sp, sp, #40, 0  ; 0x28
   116ac:       e3a00000        mov     r0, #0, 0
   116b0:       e58d0024        str     r0, [sp, #36]   ; 0x24
   116b4:       e59f107c        ldr     r1, [pc, #124]  ; 11738 <main+0x90>
   116b8:       e58d101c        str     r1, [sp, #28]
   116bc:       e3a01206        mov     r1, #1610612736 ; 0x60000000
   116c0:       e58d1018        str     r1, [sp, #24]
   116c4:       e59f1070        ldr     r1, [pc, #112]  ; 1173c <main+0x94>
   116c8:       e58d1014        str     r1, [sp, #20]
   116cc:       e3a01103        mov     r1, #-1073741824        ; 0xc0000000
   116d0:       e58d1010        str     r1, [sp, #16]
   116d4:       ed9d0b06        vldr    d0, [sp, #24]
   116d8:       ed9f1b12        vldr    d1, [pc, #72]   ; 11728 <main+0x80>
   116dc:       eeb40b41        vcmp.f64        d0, d1
   116e0:       eef1fa10        vmrs    APSR_nzcv, fpscr
   116e4:       e1a01000        mov     r1, r0
   116e8:       c3a01001        movgt   r1, #1, 0
   116ec:       e58d100c        str     r1, [sp, #12]
   116f0:       ed9d0b04        vldr    d0, [sp, #16]
   116f4:       ed9f1b0d        vldr    d1, [pc, #52]   ; 11730 <main+0x88>
   116f8:       eeb40b41        vcmp.f64        d0, d1
   116fc:       eef1fa10        vmrs    APSR_nzcv, fpscr
   11700:       e1a01000        mov     r1, r0
   11704:       c3a01001        movgt   r1, #1, 0
   11708:       e58d1008        str     r1, [sp, #8]
   1170c:       ed9d0b04        vldr    d0, [sp, #16]
   11710:       ed9d1b06        vldr    d1, [sp, #24]
   11714:       ee300b41        vsub.f64        d0, d0, d1
   11718:       ed8d0b00        vstr    d0, [sp]
   1171c:       e28dd028        add     sp, sp, #40, 0  ; 0x28
   11720:       e12fff1e        bx      lr
   11724:       e1a00000        nop                     ; (mov r0, r0)
   11728:       00000000        .word   0x00000000
   1172c:       7ff00000        .word   0x7ff00000
   11730:       00000000        .word   0x00000000
   11734:       fff00000        .word   0xfff00000
   11738:       3fdba5e3        .word   0x3fdba5e3
   1173c:       3fe7be76        .word   0x3fe7be76

Disassembly of section .init:

00011740 <_init>:
   11740:       e1a0c00d        mov     ip, sp
   11744:       e92dd800        push    {fp, ip, lr, pc}
   11748:       e24cb004        sub     fp, ip, #4, 0
   1174c:       e91ba800        ldmdb   fp, {fp, sp, pc}
   11750:       e1a0f00e        mov     pc, lr

Disassembly of section .fini:

00011760 <_fini>:
   11760:       e1a0c00d        mov     ip, sp
   11764:       e92dd800        push    {fp, ip, lr, pc}
   11768:       e24cb004        sub     fp, ip, #4, 0
   1176c:       e91ba800        ldmdb   fp, {fp, sp, pc}
   11770:       e1a0f00e        mov     pc, lr

Disassembly of section .plt:

00011780 <.plt>:
   11780:       e52de004        push    {lr}            ; (str lr, [sp, #-4]!)
   11784:       e28fe600        add     lr, pc, #0, 12
   11788:       e28eea02        add     lr, lr, #8192   ; 0x2000
   1178c:       e5bef110        ldr     pc, [lr, #272]! ; 0x110
   11790:       d4d4d4d4        .word   0xd4d4d4d4
   11794:       d4d4d4d4        .word   0xd4d4d4d4
   11798:       d4d4d4d4        .word   0xd4d4d4d4
   1179c:       d4d4d4d4        .word   0xd4d4d4d4
   117a0:       e28fc600        add     ip, pc, #0, 12
   117a4:       e28cca02        add     ip, ip, #8192   ; 0x2000
   117a8:       e5bcf0f8        ldr     pc, [ip, #248]! ; 0xf8
   117ac:       d4d4d4d4        .word   0xd4d4d4d4
   117b0:       e28fc600        add     ip, pc, #0, 12
   117b4:       e28cca02        add     ip, ip, #8192   ; 0x2000
   117b8:       e5bcf0ec        ldr     pc, [ip, #236]! ; 0xec
   117bc:       d4d4d4d4        .word   0xd4d4d4d4
   117c0:       e28fc600        add     ip, pc, #0, 12
   117c4:       e28cca02        add     ip, ip, #8192   ; 0x2000
   117c8:       e5bcf0e0        ldr     pc, [ip, #224]! ; 0xe0
   117cc:       d4d4d4d4        .word   0xd4d4d4d4
   117d0:       e28fc600        add     ip, pc, #0, 12
   117d4:       e28cca02        add     ip, ip, #8192   ; 0x2000
   117d8:       e5bcf0d4        ldr     pc, [ip, #212]! ; 0xd4
   117dc:       d4d4d4d4        .word   0xd4d4d4d4

I‘ll disassemble the bootstrap compiler later with 13-CURRENT. Please let me know if you need anything else. I could also provide SSH to a FreeBSD on RPi-B if you like. Thank you very much!

@randall77
Copy link
Contributor

@randall77 randall77 commented Jun 27, 2020

   116dc:       eeb40b41        vcmp.f64        d0, d1
   116e0:       eef1fa10        vmrs    APSR_nzcv, fpscr

Your C code does produce the same instruction that was faulting in the Go code.
The disassemblers agree now, at least.

I don't understand how the Go program faults on that instruction, but the C code passes.

@davecheney
Copy link
Contributor

@davecheney davecheney commented Jun 28, 2020

Is there some metadata in the elf header that may be missing in the go binary? Something that suggests the FP model used in the binary?

@seasox
Copy link
Author

@seasox seasox commented Jun 28, 2020

I've attached the full disassembly. Created with FreeBSD 13-CURRENT, go bootstrap 1.14. I will reach out to the FreeBSD ARM community today, maybe any of them has another idea.

compile-dump.txt.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.