golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.89k stars 17.52k forks source link

RaspberryPi: fmt test failed when GOARM=5 is not set #3745

Closed tjyang closed 9 years ago

tjyang commented 12 years ago
What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. hg pull ;hg update;hg id

gobuild@raspberrypi:~/go/src$ hg id
5e3661048f2e+ tip
gobuild@raspberrypi:~/go/src$

2. check GOARM setting.
gobuild@raspberrypi:~/go/src$ echo $GOARM

gobuild@raspberrypi:~/go/src$

3. cd src;./all.bash

What is the expected output?

No errors.

What do you see instead?

two test errors, fmt and eoncoding/gob(this is logged in another ticket).

ok      flag    0.120s
--- FAIL: TestNaN (0.00 seconds)
        scan_test.go:459: didn't get NaNs scanning "nan nan nan": got NaN +Inf NaN
        scan_test.go:459: didn't get NaNs scanning "NAN NAN NAN": got NaN +Inf NaN
        scan_test.go:459: didn't get NaNs scanning "NaN NaN NaN": got NaN +Inf NaN
FAIL
FAIL    fmt     0.876s
ok      go/ast  0.171s

Which operating system are you using?

gobuild@raspberrypi:~/go/src$ uname -a
Linux raspberrypi 3.1.9+ #90 Wed Apr 18 18:23:05 BST 2012 armv6l GNU/Linux
gobuild@raspberrypi:~/go/src$

Which version are you using?  (run 'go version')

gobuild@raspberrypi:~/go/src$ go version
go version weekly.2012-03-27 +5e3661048f2e
gobuild@raspberrypi:~/go/src$

Please provide any addgobuild@raspberrypi:~/go/src$ hg id
5e3661048f2e+ tip
gobuild@raspberrypi:~/go/src$
itional information below.
davecheney commented 12 years ago

Comment 1:

Can you please check that your working copy is clean. From above 
   gobuild@raspberrypi:~/go/src$ hg id 
   5e3661048f2e+ tip
The + indicates that your working copy has local changes. Do you have any CL's applied?
Cheers
Dave

Labels changed: added arch-arm, os-linux.

Status changed to WaitingForReply.

tjyang commented 12 years ago

Comment 2:

thanks for the catch, I did applied minux's CL locally. I will on a fresh tip check out.
tjyang commented 12 years ago

Comment 3:

thanks for the catch, I did apply minux's CL locally. I will on a fresh tip check out.
minux commented 12 years ago

Comment 4:

I can't reproduce this on ARMv5E (VFPv1) and ARMv7 (VFPv3/NEON).
but i did some digging, and it seems the VFP treats float32 nan as +inf.
I will test this on Kindle DX (ARM1136JF-S VPFv2).
tjyang commented 12 years ago

Comment 5:

"SIGILL: illegal instruction" error from "5e3661048f2e" tip without GOARM=5.
gobuild@raspberrypi:~/go/src$ uname -a;date
Linux raspberrypi 3.1.9+ #90 Wed Apr 18 18:23:05 BST 2012 armv6l GNU/Linux
Sun Jun 17 00:10:07 CDT 2012
gobuild@raspberrypi:~/go/src$ hg id
5e3661048f2e tip
gobuild@raspberrypi:~/go/src$ echo $GOARM
gobuild@raspberrypi:~/go/src$ ./all.bash
# Building C bootstrap tool.
cmd/dist
# Building compilers and Go bootstrap tool for host, linux/arm.
lib9
libbio
libmach
misc/pprof
cmd/addr2line
cmd/cov
cmd/nm
cmd/objdump
cmd/pack
cmd/prof
cmd/cc
cmd/gc
cmd/5l
cmd/5a
cmd/5c
cmd/5g
pkg/runtime
pkg/errors
pkg/sync/atomic
pkg/sync
pkg/io
pkg/unicode
pkg/unicode/utf8
pkg/unicode/utf16
pkg/bytes
pkg/math
pkg/strings
pkg/strconv
pkg/bufio
pkg/sort
pkg/container/heap
pkg/encoding/base64
pkg/syscall
pkg/time
pkg/os
pkg/reflect
pkg/fmt
pkg/encoding/json
pkg/flag
pkg/path/filepath
pkg/path
pkg/io/ioutil
pkg/log
pkg/regexp/syntax
pkg/regexp
pkg/go/token
pkg/go/scanner
pkg/go/ast
pkg/go/parser
pkg/os/exec
pkg/net/url
pkg/text/template/parse
pkg/text/template
pkg/go/doc
pkg/go/build
cmd/go
SIGILL: illegal instruction
PC=0x6bb40
math.init·1()
        /usbpub/home/gobuild/go/src/pkg/math/pow10.go:34 +0x28
math.init()
        /usbpub/home/gobuild/go/src/pkg/math/unsafe.go:21 +0x70
strconv.init()
        /usbpub/home/gobuild/go/src/pkg/strconv/quote.go:441 +0x70
go/parser.init()
        /usbpub/home/gobuild/go/src/pkg/go/parser/parser.go:2343 +0x78
main.init()
        /usbpub/home/gobuild/go/src/cmd/go/vet.go:37 +0x78
goroutine 2 [runnable]:
created by runtime.main
        /usbpub/home/gobuild/go/src/pkg/runtime/proc.c:221
trap    0x6
error   0x0
oldmask 0x0
r0      0x6c3620
r1      0x0
r2      0x0
r3      0x401c8e58
r4      0x401c8e50
r5      0x4
r6      0x401c8e58
r7      0x18f3ac
r8      0x18f36c
r9      0x2b5768
r10     0x1083b000
fp      0x6c328a
ip      0x1ab9f4
sp      0x401c8e30
lr      0x6bc88
pc      0x6bb40
cpsr    0x20000010
fault   0x0
gobuild@raspberrypi:~/go/src$
minux commented 12 years ago

Comment 6:

the SIGILL problem is issue #3456.
tjyang commented 12 years ago

Comment 7:

This issue is an duplicate of issue #3456. this ticket should be closed.
minux commented 12 years ago

Comment 8:

does the fmt issue still exist? if it doesn't, i'm happy to mark this issue as duplicate.
tjyang commented 12 years ago

Comment 9:

No. Not far enough to reach test stage. I got above "SIGILL: illegal instruction" error
with following version.
PS: rashpberrypi was renamed to ns.
gobuild@ns ~/go $ hg pull ;hg update;hg id
pulling from https://code.google.com/p/go
searching for changes
adding changesets
adding manifests
adding file changes
added 17 changesets with 21 changes to 21 files
(run 'hg update' to get a working copy)
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
5e806355a9e1 (release-branch.go1) go1.0.2/release
gobuild@ns ~/go $ uname -a
Linux ns 3.1.9+ #125 PREEMPT Sun Jun 17 16:09:36 BST 2012 armv6l GNU/Linux
gobuild@ns ~/go $ echo $GOARM
gobuild@ns ~/go $
minux commented 12 years ago

Comment 10:

sorry for the delay. I now can reproduce the test failure on my Kindle (ARM1136JF-S w/
VFPv2).

Status changed to Accepted.

minux commented 12 years ago

Comment 11:

the NaN behavior on VFPv2 is very weird:
package main
import "unsafe"
var uvnan uint64 = 0x7FF0000000000001
func main() {
    f64 := *(*float64)(unsafe.Pointer(&uvnan))
    if f64 == f64 { println("Not NaN64!"); }
    f32 := float32(f64)
    if f32 == f32 { println("Not NaN32!"); }
}
On ARMv7, the above program outputs nothing, which is expected.
On ARM1136JF-S (w/ GOARM=7 patch), the above program outputs
"Not NAN32!", which means that on VFPv2, converting a float64 NaN
to float32 is no longer a NaN (but a +Inf).
I've also tried to clear fpscr, but the situation doesn't change.
minux commented 12 years ago

Comment 12:

a C version (go tool 5c test.c && go tool 5l test.5):
#define printf runtime·printf
void printf(char *, ...);
void main·init(void) {}
unsigned long long ·uvnan = 0x7FF0000000000001ULL;
extern double main·uvnan;
#define uvnan main·uvnan
void main·main(void) {
    float a;
    double b;
    printf("%X\n", uvnan);
    b = uvnan;
    if (b != b)
        printf("NaN64\n");
    b = a;
    if (a != a)
        printf("NaN32\n");
}
It seems the quiet NaNs are not preserved across conversion, and Signaling NaN
should be used instead.
minux commented 12 years ago

Comment 13:

could you please test this CL?
http://golang.org/cl/6344078/
davecheney commented 12 years ago

Comment 14:

Status changed to WaitingForReply.

tjyang commented 12 years ago

Comment 15:

1. apply the patches manually from http://golang.org/cl/6344078/
2. pi info

gobuild@ns ~/go/src $ hg id
50000b87157d+ tip
gobuild@ns ~/go/src $ date
Fri Jul  6 12:23:24 UTC 2012
gobuild@ns ~/go/src $ 
gobuild@ns ~/go/src $ uname -a
Linux ns 3.1.9+ #125 PREEMPT Sun Jun 17 16:09:36 BST 2012 armv6l GNU/Linux
gobuild@ns ~/go/src $
3. compile without GOARM setting.
gobuild@ns ~/go/src $ ./all.bash
# Building C bootstrap tool.
cmd/dist
# Building compilers and Go bootstrap tool for host, linux/arm.
lib9
libbio
libmach
misc/pprof
cmd/addr2line
cmd/cov
cmd/nm
cmd/objdump
cmd/pack
cmd/prof
cmd/cc
cmd/gc
cmd/5l
cmd/5a
cmd/5c
cmd/5g
pkg/runtime
pkg/errors
pkg/sync/atomic
pkg/sync
pkg/io
pkg/unicode
pkg/unicode/utf8
pkg/unicode/utf16
pkg/bytes
pkg/math
pkg/strings
pkg/strconv
pkg/bufio
pkg/sort
pkg/container/heap
pkg/encoding/base64
pkg/syscall
pkg/time
pkg/os
pkg/reflect
pkg/fmt
pkg/encoding/json
pkg/flag
pkg/path/filepath
pkg/path
pkg/io/ioutil
pkg/log
pkg/regexp/syntax
pkg/regexp
pkg/go/token
pkg/go/scanner
pkg/go/ast
pkg/go/parser
pkg/os/exec
pkg/net/url
pkg/text/template/parse
pkg/text/template
pkg/go/doc
pkg/go/build
cmd/go
SIGILL: illegal instruction
PC=0x6bfa4
math.init·1()
        /home/gobuild/go/src/pkg/math/pow10.go:34 +0x28
math.init()
        /home/gobuild/go/src/pkg/math/unsafe.go:21 +0x70
strconv.init()
        /home/gobuild/go/src/pkg/strconv/quote.go:441 +0x70
go/parser.init()
        /home/gobuild/go/src/pkg/go/parser/parser.go:2344 +0x78
main.init()
        /home/gobuild/go/src/cmd/go/vet.go:37 +0x78
goroutine 2 [runnable]:
created by runtime.main
        /home/gobuild/go/src/pkg/runtime/proc.c:220
trap    0x6
error   0x0
oldmask 0x0
r0      0x6c88a8
r1      0x0
r2      0x0
r3      0x40173e58
r4      0x40173e50
r5      0x4
r6      0x40173e58
r7      0x191af0
r8      0x191ab0
r9      0x2ba9f0
r10     0x10837000
fp      0x6c8512
ip      0x1ae280
sp      0x40173e30
lr      0x6c0ec
pc      0x6bfa4
cpsr    0x20000010
fault   0x0
4. compile with GOARM=5 setting.
gobuild@ns ~/go/src $ GOARM=5 ./all.bash
# Building C bootstrap tool.
cmd/dist
# Building compilers and Go bootstrap tool for host, linux/arm.
lib9
libbio
libmach
misc/pprof
cmd/addr2line
cmd/cov
cmd/nm
cmd/objdump
cmd/pack
cmd/prof
cmd/cc
cmd/gc
cmd/5l
cmd/5a
cmd/5c
cmd/5g
pkg/runtime
pkg/errors
pkg/sync/atomic
pkg/sync
pkg/io
pkg/unicode
pkg/unicode/utf8
pkg/unicode/utf16
pkg/bytes
pkg/math
pkg/strings
pkg/strconv
pkg/bufio
pkg/sort
pkg/container/heap
pkg/encoding/base64
pkg/syscall
pkg/time
pkg/os
pkg/reflect
pkg/fmt
pkg/encoding/json
pkg/flag
pkg/path/filepath
pkg/path
pkg/io/ioutil
pkg/log
pkg/regexp/syntax
pkg/regexp
pkg/go/token
pkg/go/scanner
pkg/go/ast
pkg/go/parser
pkg/os/exec
pkg/net/url
pkg/text/template/parse
pkg/text/template
pkg/go/doc
pkg/go/build
cmd/go
# Building packages and commands for linux/arm.
runtime
errors
sync/atomic
sync
io
unicode
unicode/utf8
bytes
bufio
math
syscall
time
os
strconv
reflect
fmt
sort
flag
go/token
strings
path/filepath
go/scanner
go/ast
regexp/syntax
regexp
io/ioutil
net/url
text/template/parse
text/template
go/doc
go/parser
log
path
go/build
text/tabwriter
go/printer
os/exec
cmd/api
hash
crypto
crypto/md5
encoding/binary
debug/dwarf
debug/elf
debug/macho
debug/pe
cmd/cgo
cmd/fix
container/heap
encoding/base64
unicode/utf16
encoding/json
encoding/xml
compress/flate
hash/crc32
compress/gzip
crypto/cipher
crypto/aes
crypto/des
math/rand
math/big
crypto/elliptic
crypto/hmac
crypto/rand
crypto/rc4
crypto/subtle
crypto/rsa
crypto/sha1
crypto/dsa
crypto/ecdsa
encoding/asn1
crypto/x509/pkix
encoding/pem
crypto/x509
runtime/cgo
net
crypto/tls
mime
net/textproto
mime/multipart
runtime/debug
net/http
cmd/go
archive/zip
encoding/gob
expvar
index/suffixarray
html
html/template
runtime/pprof
net/http/pprof
text/scanner
cmd/godoc
cmd/gofmt
cmd/vet
cmd/yacc
archive/tar
compress/bzip2
compress/lzw
hash/adler32
compress/zlib
container/list
container/ring
crypto/sha256
crypto/sha512
database/sql/driver
database/sql
debug/gosym
encoding/ascii85
encoding/base32
encoding/csv
encoding/hex
exp/ebnf
exp/ebnflint
exp/types
exp/gotype
exp/html/atom
exp/html
exp/inotify
exp/norm
exp/locale/collate
hash/fnv
exp/locale/collate/build
exp/proxy
exp/utf8string
hash/crc64
image/color
image
image/draw
image/gif
image/jpeg
image/png
log/syslog
math/cmplx
net/http/cgi
net/http/fcgi
net/http/httptest
net/http/httputil
net/mail
net/rpc
net/rpc/jsonrpc
net/smtp
old/netchan
os/signal
os/user
testing
testing/iotest
testing/quick
# Testing packages.
ok      cmd/api 0.291s
?       cmd/cgo [no test files]
ok      cmd/fix 37.745s
ok      cmd/go  0.297s
?       cmd/godoc       [no test files]
ok      cmd/gofmt       2.495s
?       cmd/vet [no test files]
?       cmd/yacc        [no test files]
ok      archive/tar     0.541s
ok      archive/zip     1.309s
ok      bufio   4.042s
ok      bytes   1.915s
ok      compress/bzip2  1.414s
ok      compress/flate  16.605s
ok      compress/gzip   0.384s
ok      compress/lzw    4.308s
ok      compress/zlib   31.164s
ok      container/heap  0.131s
ok      container/list  0.124s
ok      container/ring  0.352s
?       crypto  [no test files]
ok      crypto/aes      0.344s
ok      crypto/cipher   0.208s
ok      crypto/des      0.677s
ok      crypto/dsa      0.462s
ok      crypto/ecdsa    0.731s
ok      crypto/elliptic 0.428s
ok      crypto/hmac     0.153s
ok      crypto/md5      0.175s
ok      crypto/rand     0.696s
ok      crypto/rc4      0.120s
ok      crypto/rsa      7.577s
ok      crypto/sha1     0.172s
ok      crypto/sha256   0.191s
ok      crypto/sha512   0.211s
ok      crypto/subtle   0.418s
ok      crypto/tls      6.476s
ok      crypto/x509     52.392s
?       crypto/x509/pkix        [no test files]
ok      database/sql    0.344s
ok      database/sql/driver     0.122s
ok      debug/dwarf     0.308s
ok      debug/elf       0.291s
ok      debug/gosym     0.133s
ok      debug/macho     0.159s
ok      debug/pe        0.147s
ok      encoding/ascii85        0.170s
ok      encoding/asn1   0.171s
ok      encoding/base32 0.178s
ok      encoding/base64 0.171s
ok      encoding/binary 0.180s
ok      encoding/csv    0.174s
throw: runtime: out of memory
goroutine 25 [running]:
encoding/gob.(*Decoder).readMessage(0x107b3b40, 0x1000cf66, 0x1077e160)
        /home/gobuild/go/src/pkg/encoding/gob/decoder.go:92 +0x70
encoding/gob.(*Decoder).recvMessage(0x107b3b40, 0xa0fa4, 0x0)
        /home/gobuild/go/src/pkg/encoding/gob/decoder.go:84 +0x130
encoding/gob.(*Decoder).decodeTypeSequence(0x107b3b40, 0x1079d100, 0x160, 0x0)
        /home/gobuild/go/src/pkg/encoding/gob/decoder.go:142 +0x68
encoding/gob.(*Decoder).DecodeValue(0x107b3b40, 0x115150, 0x1079d1b8, 0x160, 0x0, ...)
        /home/gobuild/go/src/pkg/encoding/gob/decoder.go:206 +0x174
encoding/gob.(*Decoder).Decode(0x107b3b40, 0x115148, 0x1079d1b8, 0x10748720, 0x1076b1e0,
...)
        /home/gobuild/go/src/pkg/encoding/gob/decoder.go:185 +0x284
encoding/gob.encFuzzDec(0x1079dc38, 0x114e88, 0x1079dc10, 0x1072a3e0, 0x107361b0, ...)
        /home/gobuild/go/src/pkg/encoding/gob/codec_test.go:1429 +0x358
encoding/gob.testFuzz(0x107a1540, 0x994c53f0, 0x126fc084, 0x64, 0x400cbf98, ...)
        /home/gobuild/go/src/pkg/encoding/gob/codec_test.go:1468 +0x290
encoding/gob.TestFuzzRegressions(0x107a1540, 0xe)
        /home/gobuild/go/src/pkg/encoding/gob/codec_test.go:1457 +0xd0
testing.tRunner(0x107a1540, 0x205bcc, 0x0)
        /home/gobuild/go/src/pkg/testing/testing.go:273 +0xac
created by testing.RunTests
        /home/gobuild/go/src/pkg/testing/testing.go:349 +0x768
goroutine 1 [chan receive]:
testing.RunTests(0x10c00, 0x205ad0, 0x4d, 0x4d, 0x31901, ...)
        /home/gobuild/go/src/pkg/testing/testing.go:350 +0x788
testing.Main(0x10c00, 0x205ad0, 0x4d, 0x4d, 0x2025e8, ...)
        /home/gobuild/go/src/pkg/testing/testing.go:285 +0x70
main.main()
        /tmp/go-build133969298/encoding/gob/_test/_testmain.go:199 +0x88
goroutine 2 [syscall]:
created by runtime.main
        /home/gobuild/go/src/pkg/runtime/proc.c:220
goroutine 3 [syscall]:
created by addtimer
        /home/gobuild/go/src/pkg/runtime/ztime_linux_arm.c:72
FAIL    encoding/gob    0.425s
ok      encoding/hex    0.128s
ok      encoding/json   3.074s
ok      encoding/pem    0.209s
ok      encoding/xml    0.429s
ok      errors  0.186s
ok      exp/ebnf        0.130s
ok      exp/ebnflint    0.266s
ok      exp/gotype      14.369s
ok      exp/html        5.556s
ok      exp/html/atom   0.126s
ok      exp/inotify     1.162s
ok      exp/locale/collate      0.891s
ok      exp/locale/collate/build        0.206s
ok      exp/norm        30.862s
ok      exp/proxy       0.293s
ok      exp/types       5.588s
ok      exp/utf8string  0.133s
ok      expvar  0.198s
ok      flag    0.133s
ok      fmt     1.239s
ok      go/ast  0.221s
ok      go/build        7.332s
ok      go/doc  1.955s
ok      go/parser       1.135s
ok      go/printer      10.354s
ok      go/scanner      0.200s
ok      go/token        1.618s
?       hash    [no test files]
ok      hash/adler32    0.652s
ok      hash/crc32      0.122s
ok      hash/crc64      0.121s
ok      hash/fnv        0.124s
ok      html    0.194s
ok      html/template   1.412s
ok      image   2.023s
ok      image/color     0.216s
ok      image/draw      0.904s
?       image/gif       [no test files]
ok      image/jpeg      1.480s
ok      image/png       1.796s
ok      index/suffixarray       0.369s
ok      io      0.189s
ok      io/ioutil       0.128s
ok      log     0.185s
ok      log/syslog      0.350s
ok      math    1.201s
ok      math/big        9.741s
ok      math/cmplx      0.551s
ok      math/rand       23.467s
ok      mime    0.139s
ok      mime/multipart  2.273s
ok      net     2.581s
ok      net/http        31.588s
ok      net/http/cgi    5.662s
ok      net/http/fcgi   0.235s
ok      net/http/httptest       0.200s
ok      net/http/httputil       0.345s
?       net/http/pprof  [no test files]
ok      net/mail        0.155s
ok      net/rpc 1.205s
ok      net/rpc/jsonrpc 0.461s
ok      net/smtp        0.168s
ok      net/textproto   0.183s
ok      net/url 0.421s
ok      old/netchan     1.117s
ok      os      0.880s
ok      os/exec 3.951s
ok      os/signal       0.121s
ok      os/user 0.147s
ok      path    0.253s
ok      path/filepath   7.293s
ok      reflect 0.216s
ok      regexp  3.392s
ok      regexp/syntax   27.837s
ok      runtime 70.638s
?       runtime/cgo     [no test files]
ok      runtime/debug   0.170s
ok      runtime/pprof   5.091s
ok      sort    1.603s
ok      strconv 21.911s
ok      strings 0.281s
ok      sync    0.940s
ok      sync/atomic     0.709s
ok      syscall 0.382s
?       testing [no test files]
?       testing/iotest  [no test files]
ok      testing/quick   1.685s
ok      text/scanner    0.346s
ok      text/tabwriter  0.198s
ok      text/template   1.625s
ok      text/template/parse     0.308s
ok      time    17.426s
ok      unicode 0.136s
ok      unicode/utf16   0.120s
ok      unicode/utf8    0.190s
?       unsafe  [no test files]
gobuild@ns ~/go/src $ ^C
gobuild@ns ~/go/src $
davecheney commented 12 years ago

Comment 16:

Thanks TJ, don't forget to apply http://golang.org/cl/5987063/ to avoid the
VFP3 instruction.
You can use hg p to tell which CL's you have applied
tjyang commented 12 years ago

Comment 17:

>Thanks TJ, don't forget to apply http://golang.org/cl/5987063/ to avoid the
VFP3 instruction.
I manually using emacs to append difference from http://golang.org/cl/5987063/
and run another two compile test, pls see attached gopi.txt.
>You can use hg p to tell which CL's you have applied
I need to learn more mercurial, I only know very few hg commands.

Attachments:

  1. gopi.txt (10622 bytes)
tjyang commented 12 years ago

Comment 18:

also I can open up remote access of my pi for developer if anyone is interested. I feel
I am the bottleneck here on debugging the issue.
davecheney commented 12 years ago

Comment 19:

Hi,
You could try this http://golang.org/cl/6343082. I'm not even
sure if it does avoid calling a compiler generated init function, but
my hope is the instruction sequence will avoid the troublesome VFP3
one.
Worth a shot eh ?
davecheney commented 12 years ago

Comment 20:

Please ignore my instructions above. This doesn't solve the problem, it only moves it a
few more cycles further.
Here is some debug about the gob oom error
raspberrypi(~/go/src/pkg/encoding/gob) % go test encoding/gob -v -test.run=Fuzz
runtime.sysmap: 1048576 bytes at fixed address 0x10700000
throw: runtime: out of memory - could not mmap fixed
exit status 2
FAIL    encoding/gob    0.011s
minux commented 12 years ago

Comment 21:

This issue was closed by revision 6e9506a7b45958665c3f48deecc8555f3ee2c42.

Status changed to Fixed.