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

Test failed on arm64 #34

Closed
zhsj opened this issue Feb 29, 2020 · 45 comments · Fixed by #42
Closed

Test failed on arm64 #34

zhsj opened this issue Feb 29, 2020 · 45 comments · Fixed by #42
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@zhsj
Copy link

zhsj commented Feb 29, 2020

$ GOARCH=arm64 go test -v ./ -run TestJSONObjectToYAMLObject
=== RUN   TestJSONObjectToYAMLObject
=== RUN   TestJSONObjectToYAMLObject/nil
=== RUN   TestJSONObjectToYAMLObject/empty
=== RUN   TestJSONObjectToYAMLObject/values
--- FAIL: TestJSONObjectToYAMLObject (0.04s)
    --- PASS: TestJSONObjectToYAMLObject/nil (0.01s)
    --- PASS: TestJSONObjectToYAMLObject/empty (0.00s)
    --- FAIL: TestJSONObjectToYAMLObject/values (0.02s)
        yaml_test.go:489: jsonToYAML() = (yaml.MapSlice) (len=15 cap=15) {
             (yaml.MapItem) {
              Key: (string) (len=4) "bool",
              Value: (bool) true
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "empty map",
              Value: (yaml.MapSlice) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=11) "empty slice",
              Value: ([]interface {}) {
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=7) "float64",
              Value: (float64) 42.1
             },
             (yaml.MapItem) {
              Key: (string) (len=12) "fractionless",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=3) "int",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=5) "int64",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "int64 big",
              Value: (int) 4611686018427387904
             },
             (yaml.MapItem) {
              Key: (string) (len=3) "map",
              Value: (yaml.MapSlice) (len=1 cap=1) {
               (yaml.MapItem) {
                Key: (string) (len=3) "foo",
                Value: (string) (len=3) "bar"
               }
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=18) "negative int64 big",
              Value: (int) -4611686018427387904
             },
             (yaml.MapItem) {
              Key: (string) (len=7) "nil map",
              Value: (interface {}) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "nil slice",
              Value: (interface {}) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=5) "slice",
              Value: ([]interface {}) (len=2 cap=2) {
               (string) (len=3) "foo",
               (string) (len=3) "bar"
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=6) "string",
              Value: (string) (len=3) "foo"
             },
             (yaml.MapItem) {
              Key: (string) (len=10) "uint64 big",
              Value: (int) 9223372036854775807
             }
            }
            , want (yaml.MapSlice) (len=15 cap=15) {
             (yaml.MapItem) {
              Key: (string) (len=4) "bool",
              Value: (bool) true
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "empty map",
              Value: (yaml.MapSlice) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=11) "empty slice",
              Value: ([]interface {}) {
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=7) "float64",
              Value: (float64) 42.1
             },
             (yaml.MapItem) {
              Key: (string) (len=12) "fractionless",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=3) "int",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=5) "int64",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "int64 big",
              Value: (int) 4611686018427387904
             },
             (yaml.MapItem) {
              Key: (string) (len=3) "map",
              Value: (yaml.MapSlice) (len=1 cap=1) {
               (yaml.MapItem) {
                Key: (string) (len=3) "foo",
                Value: (string) (len=3) "bar"
               }
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=18) "negative int64 big",
              Value: (int) -4611686018427387904
             },
             (yaml.MapItem) {
              Key: (string) (len=7) "nil map",
              Value: (interface {}) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "nil slice",
              Value: (interface {}) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=5) "slice",
              Value: ([]interface {}) (len=2 cap=2) {
               (string) (len=3) "foo",
               (string) (len=3) "bar"
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=6) "string",
              Value: (string) (len=3) "foo"
             },
             (yaml.MapItem) {
              Key: (string) (len=10) "uint64 big",
              Value: (uint64) 9223372036854775808
             }
            }
        yaml_test.go:528: yaml.Unmarshal(json.Marshal(tt.input)) = (yaml.MapSlice) (len=15 cap=16) {
             (yaml.MapItem) {
              Key: (string) (len=4) "bool",
              Value: (bool) true
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "empty map",
              Value: (yaml.MapSlice) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=11) "empty slice",
              Value: ([]interface {}) {
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=7) "float64",
              Value: (float64) 42.1
             },
             (yaml.MapItem) {
              Key: (string) (len=12) "fractionless",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=3) "int",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=5) "int64",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "int64 big",
              Value: (int) 4611686018427388000
             },
             (yaml.MapItem) {
              Key: (string) (len=3) "map",
              Value: (yaml.MapSlice) (len=1 cap=1) {
               (yaml.MapItem) {
                Key: (string) (len=3) "foo",
                Value: (string) (len=3) "bar"
               }
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=18) "negative int64 big",
              Value: (int) -4611686018427388000
             },
             (yaml.MapItem) {
              Key: (string) (len=7) "nil map",
              Value: (interface {}) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "nil slice",
              Value: (interface {}) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=5) "slice",
              Value: ([]interface {}) (len=2 cap=2) {
               (string) (len=3) "foo",
               (string) (len=3) "bar"
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=6) "string",
              Value: (string) (len=3) "foo"
             },
             (yaml.MapItem) {
              Key: (string) (len=10) "uint64 big",
              Value: (uint64) 9223372036854776000
             }
            }
            , want (yaml.MapSlice) (len=15 cap=15) {
             (yaml.MapItem) {
              Key: (string) (len=4) "bool",
              Value: (bool) true
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "empty map",
              Value: (yaml.MapSlice) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=11) "empty slice",
              Value: ([]interface {}) {
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=7) "float64",
              Value: (float64) 42.1
             },
             (yaml.MapItem) {
              Key: (string) (len=12) "fractionless",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=3) "int",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=5) "int64",
              Value: (int) 42
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "int64 big",
              Value: (int) 4611686018427388000
             },
             (yaml.MapItem) {
              Key: (string) (len=3) "map",
              Value: (yaml.MapSlice) (len=1 cap=1) {
               (yaml.MapItem) {
                Key: (string) (len=3) "foo",
                Value: (string) (len=3) "bar"
               }
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=18) "negative int64 big",
              Value: (int) -4611686018427388000
             },
             (yaml.MapItem) {
              Key: (string) (len=7) "nil map",
              Value: (interface {}) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=9) "nil slice",
              Value: (interface {}) <nil>
             },
             (yaml.MapItem) {
              Key: (string) (len=5) "slice",
              Value: ([]interface {}) (len=2 cap=2) {
               (string) (len=3) "foo",
               (string) (len=3) "bar"
              }
             },
             (yaml.MapItem) {
              Key: (string) (len=6) "string",
              Value: (string) (len=3) "foo"
             },
             (yaml.MapItem) {
              Key: (string) (len=10) "uint64 big",
              Value: (int) -9223372036854775000
             }
            }
            
            json: {"bool":true,"empty map":{},"empty slice":[],"float64":42.1,"fractionless":42,"int":42,"int64":42,"int64 big":4611686018427388000,"map":{"foo":"bar"},"negative int64 big":-4611686018427388000,"nil map":null,"nil slice":null,"slice":["foo","bar"],"string":"foo","uint64 big":9223372036854776000}
FAIL
FAIL    sigs.k8s.io/yaml        0.104s
FAIL

The diff is

              },
              (yaml.MapItem) {
               Key: (string) (len=10) "uint64 big",
-              Value: (int) 9223372036854775807
+              Value: (uint64) 9223372036854775808
              }
             }

and

-(yaml.MapSlice) (len=15 cap=16) {
+(yaml.MapSlice) (len=15 cap=15) {
              (yaml.MapItem) {
               Key: (string) (len=4) "bool",
               Value: (bool) true
@@ -66,6 +66,7 @@
              },
              (yaml.MapItem) {
               Key: (string) (len=10) "uint64 big",
-              Value: (uint64) 9223372036854776000
+              Value: (int) -9223372036854775000
              }
             }
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 29, 2020
@neolit123
Copy link
Member

neolit123 commented May 29, 2020

/remove-lifecycle stale
/help
/kind bug

looks like this went unnoticed, but i find the signed / unsigned diff quite odd, if that is comparing amd64 and arm64.

we don't have CI signal for arm64 but it is claimed as a supported platform, so PRs to fix this bug are welcome.

@k8s-ci-robot
Copy link

@neolit123:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/remove-lifecycle stale
/help
/kind bug

looks like this went unnoticed, but i find the signed / unsigned diff quite odd, if that is comparing amd64 and arm64.

we don't have CI signal for arm64 but it is claimed as a supported platform, so PRs welcome.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 29, 2020
@eclipseo
Copy link

I'm having a similar issue on aarch64, s390x and ppc64: https://koji.fedoraproject.org/koji/taskinfo?taskID=45709245

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 12, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 12, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@neolit123
Copy link
Member

neolit123 commented Nov 11, 2020

/reopen
the tests should pass on arm64.

EDIT: looks like more platforms have the problem:

I'm having a similar issue on aarch64, s390x and ppc64: https://koji.fedoraproject.org/koji/taskinfo?taskID=45709245

#34 (comment)

@k8s-ci-robot
Copy link

@neolit123: Reopened this issue.

In response to this:

/reopen
the tests should pass on arm64.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot reopened this Nov 11, 2020
@afbjorklund
Copy link

afbjorklund commented Nov 11, 2020

@neolit123 : there is something really funky going on in the FPU or math libs on arm64:

package main

import "fmt"
import "math"

func main() {
	x := float64(9223372036854775808.0)
	fmt.Printf("f %f\n", float64(x))
	fmt.Printf("b %b\n", math.Float64bits(x))
	fmt.Printf("i %d\n", int64(x))
	fmt.Printf("u %d\n", uint64(x))

	y := math.Pow(2,63)
	fmt.Printf("f %f\n", float64(y))
	fmt.Printf("b %b\n", math.Float64bits(y))
	fmt.Printf("i %d\n", int64(y))
	fmt.Printf("u %d\n", uint64(y))
}

Even though the floating point number is binary indentical, it still produces different results ?!?

f 9223372036854775808.000000
b 100001111100000000000000000000000000000000000000000000000000000
i -9223372036854775808
u 9223372036854775808
f 9223372036854775808.000000
b 100001111100000000000000000000000000000000000000000000000000000
i 9223372036854775807
u 9223372036854775808

@neolit123
Copy link
Member

neolit123 commented Nov 11, 2020

i 9223372036854775807

this is not right. (EDIT: after some digging, more in the lines of "potential behavior")
the int64 cast in the second case appears to be dropping the sign bit from the double, resulting in 0x43E instead of 0xC3E. capping at the positive limit for int64.

can you please:

go tool compile -S main.go > main.s

and share the output here. i doubt this is hardware related (e.g. VFP) and seems more like a compiler bug.

  • what is the golang version?
  • are your running on QEMU or real HW; what is the setup / spec?

we might have to report this to golang.

@neolit123
Copy link
Member

neolit123 commented Nov 12, 2020

just ran the same code with:

C:\bin\qemu>qemu-system-aarch64.exe --version
QEMU emulator version 5.1.0 (v5.1.0-11824-g8699890d91-dirty)
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

qemu-system-aarch64 -m 2048 -cpu cortex-a72 -smp 4 -M virt -nographic -bios QEMU_EFI.fd -drive if=none,file=.\focal-server-cloudimg-arm64.img,id=hd0 -device virtio-blk-device,drive=hd0 -drive file=linux.img,format=raw -device virtio-net-device,netdev=net0 -netdev user,hostfwd=tcp:127.0.0.1:2222-:22,id=net0

in:

ubuntu@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal
ubuntu@ubuntu:~$ uname -m
aarch64

using:

ubuntu@ubuntu:~$ go version
go version go1.15.4 linux/arm64

and got:

f 9223372036854775808.000000
b 100001111100000000000000000000000000000000000000000000000000000
i 9223372036854775807
u 9223372036854775808
f 9223372036854775808.000000
b 100001111100000000000000000000000000000000000000000000000000000
i 9223372036854775807
u 9223372036854775808

which now has the int64() cast print MAX_INT64 for both cases.

ubuntu@ubuntu:~$ go tool objdump -S main | grep "/home/ubuntu/main.go" -A 300
TEXT main.main(SB) /home/ubuntu/main.go
func main() {
  0x9d720               f9400b81                MOVD 16(R28), R1
  0x9d724               d101c3e2                SUB $112, RSP, R2
  0x9d728               eb01005f                CMP R1, R2
  0x9d72c               54001e09                BLS 240(PC)
  0x9d730               f8110ffe                MOVD.W R30, -240(RSP)
  0x9d734               f81f83fd                MOVD R29, -8(RSP)
  0x9d738               d10023fd                SUB $8, RSP, R29
        fmt.Printf("f %f\n", float64(x))
  0x9d73c               f000021b                ADRP 274432(PC), R27
  0x9d740               9128437b                ADD $2576, R27, R27
  0x9d744               fd400360                FMOVD (R27), F0
  0x9d748               fd0007e0                FMOVD F0, 8(RSP)
  0x9d74c               97fdedf5                CALL runtime.convT64(SB)
  0x9d750               f9400be0                MOVD 16(RSP), R0
  0x9d754               a90bffff                STP (ZR, ZR), 184(RSP)
  0x9d758               90000061                ADRP 49152(PC), R1
  0x9d75c               913b8021                ADD $3808, R1, R1
  0x9d760               f9005fe1                MOVD R1, 184(RSP)
  0x9d764               f90063e0                MOVD R0, 192(RSP)
        return Fprintf(os.Stdout, format, a...)
  0x9d768               9000065b                ADRP 819200(PC), R27
  0x9d76c               9124237b                ADD $2312, R27, R27
  0x9d770               f9400360                MOVD (R27), R0
  0x9d774               b0000222                ADRP 282624(PC), R2
  0x9d778               911d0042                ADD $1856, R2, R2
  0x9d77c               f90007e2                MOVD R2, 8(RSP)
  0x9d780               f9000be0                MOVD R0, 16(RSP)
  0x9d784               b0000120                ADRP 151552(PC), R0
  0x9d788               913a4000                ADD $3728, R0, R0
  0x9d78c               f9000fe0                MOVD R0, 24(RSP)
  0x9d790               d28000a3                MOVD $5, R3
  0x9d794               f90013e3                MOVD R3, 32(RSP)
  0x9d798               9102e3e4                ADD $184, RSP, R4
  0x9d79c               f90017e4                MOVD R4, 40(RSP)
  0x9d7a0               b24003e4                ORR $1, ZR, R4
  0x9d7a4               f9001be4                MOVD R4, 48(RSP)
  0x9d7a8               f9001fe4                MOVD R4, 56(RSP)
  0x9d7ac               97ffe461                CALL fmt.Fprintf(SB)
        fmt.Printf("b %b\n", math.Float64bits(x))
  0x9d7b0               d2e87c00                MOVD $4890909195324358656, R0
  0x9d7b4               f90007e0                MOVD R0, 8(RSP)
  0x9d7b8               97fdedda                CALL runtime.convT64(SB)
  0x9d7bc               f9400be0                MOVD 16(RSP), R0
  0x9d7c0               a90affff                STP (ZR, ZR), 168(RSP)
  0x9d7c4               b0000061                ADRP 53248(PC), R1
  0x9d7c8               91298021                ADD $2656, R1, R1
  0x9d7cc               f90057e1                MOVD R1, 168(RSP)
  0x9d7d0               f9005be0                MOVD R0, 176(RSP)
        return Fprintf(os.Stdout, format, a...)
  0x9d7d4               9000065b                ADRP 819200(PC), R27
  0x9d7d8               9124237b                ADD $2312, R27, R27
  0x9d7dc               f9400360                MOVD (R27), R0
  0x9d7e0               b0000222                ADRP 282624(PC), R2
  0x9d7e4               911d0042                ADD $1856, R2, R2
  0x9d7e8               f90007e2                MOVD R2, 8(RSP)
  0x9d7ec               f9000be0                MOVD R0, 16(RSP)
  0x9d7f0               b0000120                ADRP 151552(PC), R0
  0x9d7f4               9139c800                ADD $3698, R0, R0
  0x9d7f8               f9000fe0                MOVD R0, 24(RSP)
  0x9d7fc               d28000a3                MOVD $5, R3
  0x9d800               f90013e3                MOVD R3, 32(RSP)
  0x9d804               9102a3e4                ADD $168, RSP, R4
  0x9d808               f90017e4                MOVD R4, 40(RSP)
  0x9d80c               b24003e4                ORR $1, ZR, R4
  0x9d810               f9001be4                MOVD R4, 48(RSP)
  0x9d814               f9001fe4                MOVD R4, 56(RSP)
  0x9d818               97ffe446                CALL fmt.Fprintf(SB)
        fmt.Printf("i %d\n", int64(x))
  0x9d81c               92f00000                MOVD $9223372036854775807, R0
  0x9d820               f90007e0                MOVD R0, 8(RSP)
  0x9d824               97fdedbf                CALL runtime.convT64(SB)
  0x9d828               f9400be0                MOVD 16(RSP), R0
  0x9d82c               a909ffff                STP (ZR, ZR), 152(RSP)
  0x9d830               b0000061                ADRP 53248(PC), R1
  0x9d834               910e8021                ADD $928, R1, R1
  0x9d838               f9004fe1                MOVD R1, 152(RSP)
  0x9d83c               f90053e0                MOVD R0, 160(RSP)
        return Fprintf(os.Stdout, format, a...)
  0x9d840               9000065b                ADRP 819200(PC), R27
  0x9d844               9124237b                ADD $2312, R27, R27
  0x9d848               f9400360                MOVD (R27), R0
  0x9d84c               b0000222                ADRP 282624(PC), R2
  0x9d850               911d0042                ADD $1856, R2, R2
  0x9d854               f90007e2                MOVD R2, 8(RSP)
  0x9d858               f9000be0                MOVD R0, 16(RSP)
  0x9d85c               b0000120                ADRP 151552(PC), R0
  0x9d860               913acc00                ADD $3763, R0, R0
  0x9d864               f9000fe0                MOVD R0, 24(RSP)
  0x9d868               d28000a3                MOVD $5, R3
  0x9d86c               f90013e3                MOVD R3, 32(RSP)
  0x9d870               910263e4                ADD $152, RSP, R4
  0x9d874               f90017e4                MOVD R4, 40(RSP)
  0x9d878               b24003e4                ORR $1, ZR, R4
  0x9d87c               f9001be4                MOVD R4, 48(RSP)
  0x9d880               f9001fe4                MOVD R4, 56(RSP)
  0x9d884               97ffe42b                CALL fmt.Fprintf(SB)
        fmt.Printf("u %d\n", uint64(x))
  0x9d888               f000021b                ADRP 274432(PC), R27
  0x9d88c               9128437b                ADD $2576, R27, R27
  0x9d890               fd400360                FMOVD (R27), F0
  0x9d894               9e790000                FCVTZUD F0, R0
  0x9d898               f90007e0                MOVD R0, 8(RSP)
  0x9d89c               97fdeda1                CALL runtime.convT64(SB)
  0x9d8a0               f9400be0                MOVD 16(RSP), R0
  0x9d8a4               a908ffff                STP (ZR, ZR), 136(RSP)
  0x9d8a8               b0000061                ADRP 53248(PC), R1
  0x9d8ac               91298021                ADD $2656, R1, R1
  0x9d8b0               f90047e1                MOVD R1, 136(RSP)
  0x9d8b4               f9004be0                MOVD R0, 144(RSP)
        return Fprintf(os.Stdout, format, a...)
  0x9d8b8               9000065b                ADRP 819200(PC), R27
  0x9d8bc               9124237b                ADD $2312, R27, R27
  0x9d8c0               f9400360                MOVD (R27), R0
  0x9d8c4               b0000222                ADRP 282624(PC), R2
  0x9d8c8               911d0042                ADD $1856, R2, R2
  0x9d8cc               f90007e2                MOVD R2, 8(RSP)
  0x9d8d0               f9000be0                MOVD R0, 16(RSP)
  0x9d8d4               b0000120                ADRP 151552(PC), R0
  0x9d8d8               913c2000                ADD $3848, R0, R0
  0x9d8dc               f9000fe0                MOVD R0, 24(RSP)
  0x9d8e0               d28000a3                MOVD $5, R3
  0x9d8e4               f90013e3                MOVD R3, 32(RSP)
  0x9d8e8               910223e4                ADD $136, RSP, R4
  0x9d8ec               f90017e4                MOVD R4, 40(RSP)
  0x9d8f0               b24003e4                ORR $1, ZR, R4
  0x9d8f4               f9001be4                MOVD R4, 48(RSP)
  0x9d8f8               f9001fe4                MOVD R4, 56(RSP)
  0x9d8fc               97ffe40d                CALL fmt.Fprintf(SB)
        y := math.Pow(2,63)
  0x9d900               f000021b                ADRP 274432(PC), R27
  0x9d904               911fa37b                ADD $2024, R27, R27
  0x9d908               fd400360                FMOVD (R27), F0
  0x9d90c               fd0007e0                FMOVD F0, 8(RSP)
  0x9d910               f000021b                ADRP 274432(PC), R27
  0x9d914               9122837b                ADD $2208, R27, R27
  0x9d918               fd400360                FMOVD (R27), F0
  0x9d91c               fd000be0                FMOVD F0, 16(RSP)
  0x9d920               97ff4e58                CALL math.Pow(SB)
  0x9d924               fd400fe0                FMOVD 24(RSP), F0
  0x9d928               fd0033e0                FMOVD F0, 96(RSP)
        fmt.Printf("f %f\n", float64(y))
  0x9d92c               fd0007e0                FMOVD F0, 8(RSP)
  0x9d930               97fded7c                CALL runtime.convT64(SB)
  0x9d934               f9400be0                MOVD 16(RSP), R0
  0x9d938               a907ffff                STP (ZR, ZR), 120(RSP)
  0x9d93c               90000061                ADRP 49152(PC), R1
  0x9d940               913b8021                ADD $3808, R1, R1
  0x9d944               f9003fe1                MOVD R1, 120(RSP)
  0x9d948               f90043e0                MOVD R0, 128(RSP)
        return Fprintf(os.Stdout, format, a...)
  0x9d94c               9000065b                ADRP 819200(PC), R27
  0x9d950               9124237b                ADD $2312, R27, R27
  0x9d954               f9400360                MOVD (R27), R0
  0x9d958               b0000221                ADRP 282624(PC), R1
  0x9d95c               911d0021                ADD $1856, R1, R1
  0x9d960               f90007e1                MOVD R1, 8(RSP)
  0x9d964               f9000be0                MOVD R0, 16(RSP)
  0x9d968               b0000120                ADRP 151552(PC), R0
  0x9d96c               913a4000                ADD $3728, R0, R0
  0x9d970               f9000fe0                MOVD R0, 24(RSP)
  0x9d974               d28000a0                MOVD $5, R0
  0x9d978               f90013e0                MOVD R0, 32(RSP)
  0x9d97c               9101e3e2                ADD $120, RSP, R2
  0x9d980               f90017e2                MOVD R2, 40(RSP)
  0x9d984               b24003e2                ORR $1, ZR, R2
  0x9d988               f9001be2                MOVD R2, 48(RSP)
  0x9d98c               f9001fe2                MOVD R2, 56(RSP)
  0x9d990               97ffe3e8                CALL fmt.Fprintf(SB)
        fmt.Printf("b %b\n", math.Float64bits(y))
  0x9d994               fd4033e0                FMOVD 96(RSP), F0
  0x9d998               fd0007e0                FMOVD F0, 8(RSP)
  0x9d99c               97fded61                CALL runtime.convT64(SB)
  0x9d9a0               f9400be0                MOVD 16(RSP), R0
  0x9d9a4               a906ffff                STP (ZR, ZR), 104(RSP)
  0x9d9a8               b0000061                ADRP 53248(PC), R1
  0x9d9ac               91298021                ADD $2656, R1, R1
  0x9d9b0               f90037e1                MOVD R1, 104(RSP)
  0x9d9b4               f9003be0                MOVD R0, 112(RSP)
        return Fprintf(os.Stdout, format, a...)
  0x9d9b8               9000065b                ADRP 819200(PC), R27
  0x9d9bc               9124237b                ADD $2312, R27, R27
  0x9d9c0               f9400360                MOVD (R27), R0
  0x9d9c4               b0000222                ADRP 282624(PC), R2
  0x9d9c8               911d0042                ADD $1856, R2, R2
  0x9d9cc               f90007e2                MOVD R2, 8(RSP)
  0x9d9d0               f9000be0                MOVD R0, 16(RSP)
  0x9d9d4               b0000120                ADRP 151552(PC), R0
  0x9d9d8               9139c800                ADD $3698, R0, R0
  0x9d9dc               f9000fe0                MOVD R0, 24(RSP)
  0x9d9e0               d28000a0                MOVD $5, R0
  0x9d9e4               f90013e0                MOVD R0, 32(RSP)
  0x9d9e8               9101a3e3                ADD $104, RSP, R3
  0x9d9ec               f90017e3                MOVD R3, 40(RSP)
  0x9d9f0               b24003e3                ORR $1, ZR, R3
  0x9d9f4               f9001be3                MOVD R3, 48(RSP)
  0x9d9f8               f9001fe3                MOVD R3, 56(RSP)
  0x9d9fc               97ffe3cd                CALL fmt.Fprintf(SB)
        fmt.Printf("i %d\n", int64(y))
  0x9da00               fd4033e0                FMOVD 96(RSP), F0
  0x9da04               9e780000                FCVTZSD F0, R0
  0x9da08               f90007e0                MOVD R0, 8(RSP)
  0x9da0c               97fded45                CALL runtime.convT64(SB)
  0x9da10               f9400be0                MOVD 16(RSP), R0
  0x9da14               a90dffff                STP (ZR, ZR), 216(RSP)
  0x9da18               b0000061                ADRP 53248(PC), R1
  0x9da1c               910e8021                ADD $928, R1, R1
  0x9da20               f9006fe1                MOVD R1, 216(RSP)
  0x9da24               f90073e0                MOVD R0, 224(RSP)
        return Fprintf(os.Stdout, format, a...)
  0x9da28               9000065b                ADRP 819200(PC), R27
  0x9da2c               9124237b                ADD $2312, R27, R27
  0x9da30               f9400360                MOVD (R27), R0
  0x9da34               b0000221                ADRP 282624(PC), R1
  0x9da38               911d0021                ADD $1856, R1, R1
  0x9da3c               f90007e1                MOVD R1, 8(RSP)
  0x9da40               f9000be0                MOVD R0, 16(RSP)
  0x9da44               b0000120                ADRP 151552(PC), R0
  0x9da48               913acc00                ADD $3763, R0, R0
  0x9da4c               f9000fe0                MOVD R0, 24(RSP)
  0x9da50               d28000a0                MOVD $5, R0
  0x9da54               f90013e0                MOVD R0, 32(RSP)
  0x9da58               910363e2                ADD $216, RSP, R2
  0x9da5c               f90017e2                MOVD R2, 40(RSP)
  0x9da60               b24003e2                ORR $1, ZR, R2
  0x9da64               f9001be2                MOVD R2, 48(RSP)
  0x9da68               f9001fe2                MOVD R2, 56(RSP)
  0x9da6c               97ffe3b1                CALL fmt.Fprintf(SB)
        fmt.Printf("u %d\n", uint64(y))
  0x9da70               fd4033e0                FMOVD 96(RSP), F0
  0x9da74               9e790000                FCVTZUD F0, R0
  0x9da78               f90007e0                MOVD R0, 8(RSP)
  0x9da7c               97fded29                CALL runtime.convT64(SB)
  0x9da80               f9400be0                MOVD 16(RSP), R0
  0x9da84               a90cffff                STP (ZR, ZR), 200(RSP)
  0x9da88               b0000061                ADRP 53248(PC), R1
  0x9da8c               91298021                ADD $2656, R1, R1
  0x9da90               f90067e1                MOVD R1, 200(RSP)
  0x9da94               f9006be0                MOVD R0, 208(RSP)
        return Fprintf(os.Stdout, format, a...)
  0x9da98               9000065b                ADRP 819200(PC), R27
  0x9da9c               9124237b                ADD $2312, R27, R27
  0x9daa0               f9400360                MOVD (R27), R0
  0x9daa4               b0000221                ADRP 282624(PC), R1
  0x9daa8               911d0021                ADD $1856, R1, R1
  0x9daac               f90007e1                MOVD R1, 8(RSP)
  0x9dab0               f9000be0                MOVD R0, 16(RSP)
  0x9dab4               b0000120                ADRP 151552(PC), R0
  0x9dab8               913c2000                ADD $3848, R0, R0
  0x9dabc               f9000fe0                MOVD R0, 24(RSP)
  0x9dac0               d28000a0                MOVD $5, R0
  0x9dac4               f90013e0                MOVD R0, 32(RSP)
  0x9dac8               910323e0                ADD $200, RSP, R0
  0x9dacc               f90017e0                MOVD R0, 40(RSP)
  0x9dad0               b24003e0                ORR $1, ZR, R0
  0x9dad4               f9001be0                MOVD R0, 48(RSP)
  0x9dad8               f9001fe0                MOVD R0, 56(RSP)
  0x9dadc               97ffe395                CALL fmt.Fprintf(SB)
        fmt.Printf("u %d\n", uint64(y))
  0x9dae0               f85f83fd                LDUR -8(RSP), R29
  0x9dae4               f84f07fe                MOVD.P 240(RSP), R30
  0x9dae8               d65f03c0                RET
func main() {
  0x9daec               aa1e03e3                MOVD R30, R3
  0x9daf0               97ff2edc                CALL runtime.morestack_noctxt(SB)
  0x9daf4               17ffff0b                JMP main.main(SB)
  0x9daf8               00000000                ?
  0x9dafc               00000000                ?

it appears to be pining the literal of MAX_INT64 (9223372036854775807) in the first case and fetching it from the stack for the second case. i think this is just a matter of optimization and the fact that 9223372036854775808 overflows int64 can make the compiler make volatile choices.

similar can be observed with GCC.
without optimization you can see a cvttsd2siq that would result in a -9223372036854775808, but with -O3 the compiler just pins the literal of 9223372036854775807 with a movabsq. GCC at least is consistent in optimizing away in a similar way, unlike what you saw in your output, but i wouldn't rely on GCC always doing that.

so unit testing around maximums and trying to get consistent results from optimizing compilers in a cross platform way is not something that will work very well for us here.

http://c0x.coding-guidelines.com/6.3.1.4.html

686 When a finite value of real floating type is converted to an integer type other than _Bool, the fractional part is discarded (i.e., the value is truncated toward zero).
687 If the value of the integral part cannot be represented by the integer type, the behavior is undefined.50)

cc @sttts

@afbjorklund
Copy link

i doubt this is hardware related (e.g. VFP) and seems more like a compiler bug.

* what is the golang version?

* are your running on QEMU or real HW; what is the setup / spec?

we might have to report this to golang.

I used go 1.15.2 running on amd64 (with GOARCH=arm64), and aarch64 qemu to run it (I suppose)

Re-running the same test on a Raspberry Pi 4, I also get 9223372036854775807 for both of them...

@zhsj
Copy link
Author

zhsj commented Nov 12, 2020

Not sure what happens recently, it seems the issue is gone on real HW. See the log at https://ci.debian.net/packages/g/golang-k8s-sigs-yaml/testing/arm64/ starting from 2020-03-08, the test is green.. the log is rotated, so no idea what changes..

@afbjorklund
Copy link

It was indeed the optimizer, that caused it to behave differently the first time.

         x := float64(9223372036854775808.0)
        fmt.Printf("i %d\n", int64(x))
  0x9d4fc               d2f00000                MOVD $-9223372036854775808, R0
  0x9d500               f90007e0                MOVD R0, 8(RSP)
  0x9d504               97fdee83                CALL runtime.convT64(SB)
  0x9d508               f9400be0                MOVD 16(RSP), R0
  0x9d50c               a906ffff                STP (ZR, ZR), 104(RSP)
  0x9d510               b0000061                ADRP 53248(PC), R1
  0x9d514               910f8021                ADD $992, R1, R1
  0x9d518               f90037e1                MOVD R1, 104(RSP)
  0x9d51c               f9003be0                MOVD R0, 112(RSP)

         y := math.Pow(2,63)
  0x9d568               f000021b                ADRP 274432(PC), R27
  0x9d56c               9126037b                ADD $2432, R27, R27
  0x9d570               fd400360                FMOVD (R27), F0
  0x9d574               fd0007e0                FMOVD F0, 8(RSP)
  0x9d578               f000021b                ADRP 274432(PC), R27
  0x9d57c               9128e37b                ADD $2616, R27, R27
  0x9d580               fd400360                FMOVD (R27), F0
  0x9d584               fd000be0                FMOVD F0, 16(RSP)
  0x9d588               97ff4eb6                CALL math.Pow(SB)
  0x9d58c               fd400fe0                FMOVD 24(RSP), F0
        fmt.Printf("i %d\n", int64(y))
  0x9d590               9e780000                FCVTZSD F0, R0
  0x9d594               f90007e0                MOVD R0, 8(RSP)
  0x9d598               97fdee5e                CALL runtime.convT64(SB)
  0x9d59c               f9400be0                MOVD 16(RSP), R0
  0x9d5a0               a905ffff                STP (ZR, ZR), 88(RSP)
  0x9d5a4               b0000061                ADRP 53248(PC), R1
  0x9d5a8               910f8021                ADD $992, R1, R1
  0x9d5ac               f9002fe1                MOVD R1, 88(RSP)
  0x9d5b0               f90033e0                MOVD R0, 96(RSP)

@afbjorklund
Copy link

afbjorklund commented Nov 12, 2020

it seems the issue is gone on real HW

the test fails consistently on RPi4 (A72)

https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711/README.md

ubuntu@ubuntu:~/kubernetes-yaml$ grep PRETTY /etc/os-release 
PRETTY_NAME="Ubuntu 20.04.1 LTS"
ubuntu@ubuntu:~/kubernetes-yaml$ uname -m -r
5.4.0-1022-raspi aarch64
ubuntu@ubuntu:~/kubernetes-yaml$ go test -v ./ -run TestJSONObjectToYAMLObject
=== RUN   TestJSONObjectToYAMLObject
=== RUN   TestJSONObjectToYAMLObject/nil
=== RUN   TestJSONObjectToYAMLObject/empty
=== RUN   TestJSONObjectToYAMLObject/values
    yaml_test.go:489: jsonToYAML() = (yaml.MapSlice) (len=15 cap=15) {
         (yaml.MapItem) {
          Key: (string) (len=4) "bool",
          Value: (bool) true
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "empty map",
          Value: (yaml.MapSlice) 
         },
         (yaml.MapItem) {
          Key: (string) (len=11) "empty slice",
          Value: ([]interface {}) {
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=7) "float64",
          Value: (float64) 42.1
         },
         (yaml.MapItem) {
          Key: (string) (len=12) "fractionless",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=3) "int",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=5) "int64",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "int64 big",
          Value: (int) 4611686018427387904
         },
         (yaml.MapItem) {
          Key: (string) (len=3) "map",
          Value: (yaml.MapSlice) (len=1 cap=1) {
           (yaml.MapItem) {
            Key: (string) (len=3) "foo",
            Value: (string) (len=3) "bar"
           }
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=18) "negative int64 big",
          Value: (int) -4611686018427387904
         },
         (yaml.MapItem) {
          Key: (string) (len=7) "nil map",
          Value: (interface {}) 
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "nil slice",
          Value: (interface {}) 
         },
         (yaml.MapItem) {
          Key: (string) (len=5) "slice",
          Value: ([]interface {}) (len=2 cap=2) {
           (string) (len=3) "foo",
           (string) (len=3) "bar"
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=6) "string",
          Value: (string) (len=3) "foo"
         },
         (yaml.MapItem) {
          Key: (string) (len=10) "uint64 big",
          Value: (int) 9223372036854775807
         }
        }
        , want (yaml.MapSlice) (len=15 cap=15) {
         (yaml.MapItem) {
          Key: (string) (len=4) "bool",
          Value: (bool) true
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "empty map",
          Value: (yaml.MapSlice) 
         },
         (yaml.MapItem) {
          Key: (string) (len=11) "empty slice",
          Value: ([]interface {}) {
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=7) "float64",
          Value: (float64) 42.1
         },
         (yaml.MapItem) {
          Key: (string) (len=12) "fractionless",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=3) "int",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=5) "int64",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "int64 big",
          Value: (int) 4611686018427387904
         },
         (yaml.MapItem) {
          Key: (string) (len=3) "map",
          Value: (yaml.MapSlice) (len=1 cap=1) {
           (yaml.MapItem) {
            Key: (string) (len=3) "foo",
            Value: (string) (len=3) "bar"
           }
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=18) "negative int64 big",
          Value: (int) -4611686018427387904
         },
         (yaml.MapItem) {
          Key: (string) (len=7) "nil map",
          Value: (interface {}) 
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "nil slice",
          Value: (interface {}) 
         },
         (yaml.MapItem) {
          Key: (string) (len=5) "slice",
          Value: ([]interface {}) (len=2 cap=2) {
           (string) (len=3) "foo",
           (string) (len=3) "bar"
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=6) "string",
          Value: (string) (len=3) "foo"
         },
         (yaml.MapItem) {
          Key: (string) (len=10) "uint64 big",
          Value: (uint64) 9223372036854775808
         }
        }
    yaml_test.go:528: yaml.Unmarshal(json.Marshal(tt.input)) = (yaml.MapSlice) (len=15 cap=16) {
         (yaml.MapItem) {
          Key: (string) (len=4) "bool",
          Value: (bool) true
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "empty map",
          Value: (yaml.MapSlice) 
         },
         (yaml.MapItem) {
          Key: (string) (len=11) "empty slice",
          Value: ([]interface {}) {
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=7) "float64",
          Value: (float64) 42.1
         },
         (yaml.MapItem) {
          Key: (string) (len=12) "fractionless",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=3) "int",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=5) "int64",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "int64 big",
          Value: (int) 4611686018427388000
         },
         (yaml.MapItem) {
          Key: (string) (len=3) "map",
          Value: (yaml.MapSlice) (len=1 cap=1) {
           (yaml.MapItem) {
            Key: (string) (len=3) "foo",
            Value: (string) (len=3) "bar"
           }
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=18) "negative int64 big",
          Value: (int) -4611686018427388000
         },
         (yaml.MapItem) {
          Key: (string) (len=7) "nil map",
          Value: (interface {}) 
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "nil slice",
          Value: (interface {}) 
         },
         (yaml.MapItem) {
          Key: (string) (len=5) "slice",
          Value: ([]interface {}) (len=2 cap=2) {
           (string) (len=3) "foo",
           (string) (len=3) "bar"
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=6) "string",
          Value: (string) (len=3) "foo"
         },
         (yaml.MapItem) {
          Key: (string) (len=10) "uint64 big",
          Value: (uint64) 9223372036854776000
         }
        }
        , want (yaml.MapSlice) (len=15 cap=15) {
         (yaml.MapItem) {
          Key: (string) (len=4) "bool",
          Value: (bool) true
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "empty map",
          Value: (yaml.MapSlice) 
         },
         (yaml.MapItem) {
          Key: (string) (len=11) "empty slice",
          Value: ([]interface {}) {
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=7) "float64",
          Value: (float64) 42.1
         },
         (yaml.MapItem) {
          Key: (string) (len=12) "fractionless",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=3) "int",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=5) "int64",
          Value: (int) 42
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "int64 big",
          Value: (int) 4611686018427388000
         },
         (yaml.MapItem) {
          Key: (string) (len=3) "map",
          Value: (yaml.MapSlice) (len=1 cap=1) {
           (yaml.MapItem) {
            Key: (string) (len=3) "foo",
            Value: (string) (len=3) "bar"
           }
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=18) "negative int64 big",
          Value: (int) -4611686018427388000
         },
         (yaml.MapItem) {
          Key: (string) (len=7) "nil map",
          Value: (interface {}) 
         },
         (yaml.MapItem) {
          Key: (string) (len=9) "nil slice",
          Value: (interface {}) 
         },
         (yaml.MapItem) {
          Key: (string) (len=5) "slice",
          Value: ([]interface {}) (len=2 cap=2) {
           (string) (len=3) "foo",
           (string) (len=3) "bar"
          }
         },
         (yaml.MapItem) {
          Key: (string) (len=6) "string",
          Value: (string) (len=3) "foo"
         },
         (yaml.MapItem) {
          Key: (string) (len=10) "uint64 big",
          Value: (int) -9223372036854775000
         }
        }
    json: {"bool":true,"empty map":{},"empty slice":[],"float64":42.1,"fractionless":42,"int":42,"int64":42,"int64 big":4611686018427388000,"map":{"foo":"bar"},"negative int64 big":-4611686018427388000,"nil map":null,"nil slice":null,"slice":["foo","bar"],"string":"foo","uint64 big":9223372036854776000}

--- FAIL: TestJSONObjectToYAMLObject (0.00s)
--- PASS: TestJSONObjectToYAMLObject/nil (0.00s)
--- PASS: TestJSONObjectToYAMLObject/empty (0.00s)
--- FAIL: TestJSONObjectToYAMLObject/values (0.00s)
FAIL
FAIL sigs.k8s.io/yaml 0.012s
FAIL

@afbjorklund
Copy link

afbjorklund commented Nov 12, 2020

@zhsj
Copy link
Author

zhsj commented Nov 12, 2020

@zhsj : the "green" tests on debian are probably related to this patch: :-P

https://salsa.debian.org/go-team/packages/golang-k8s-sigs-yaml/-/blob/debian/sid/debian/patches/0001-only-run-TestJSONObjectToYAMLObject-on-amd64.patch

hmm, sorry I forget I disabled that... it happens so long ago.. 🤦

@neolit123
Copy link
Member

does this patch work for you @zhsj @afbjorklund ?

diff --git a/yaml_test.go b/yaml_test.go
index a88cbf3..f28cb8f 100644
--- a/yaml_test.go
+++ b/yaml_test.go
@@ -459,7 +459,7 @@ func TestJSONObjectToYAMLObject(t *testing.T) {
                                "map":                map[string]interface{}{"foo": "bar"},
                                "slice":              []interface{}{"foo", "bar"},
                                "string":             string("foo"),
-                               "uint64 big":         float64(math.Pow(2, 63)),
+                               "uint64 big":         uint64(9223372036854776000),
                        },
                        expected: yaml.MapSlice{
                                {Key: "nil slice"},
@@ -476,7 +476,7 @@ func TestJSONObjectToYAMLObject(t *testing.T) {
                                {Key: "map", Value: yaml.MapSlice{{Key: "foo", Value: "bar"}}},
                                {Key: "slice", Value: []interface{}{"foo", "bar"}},
                                {Key: "string", Value: string("foo")},
-                               {Key: "uint64 big", Value: uint64(1) << 63},
+                               {Key: "uint64 big", Value: uint64(9223372036854776000)},
                        },
                },
        }

@afbjorklund
Copy link

afbjorklund commented Nov 12, 2020

@neolit123 : it works OK with qemu, don't have the RPi4 here atm

 GOARCH=arm64 go test -v ./ -run TestJSONObjectToYAMLObject
=== RUN   TestJSONObjectToYAMLObject
=== RUN   TestJSONObjectToYAMLObject/nil
=== RUN   TestJSONObjectToYAMLObject/empty
=== RUN   TestJSONObjectToYAMLObject/values
--- PASS: TestJSONObjectToYAMLObject (0.04s)
    --- PASS: TestJSONObjectToYAMLObject/nil (0.01s)
    --- PASS: TestJSONObjectToYAMLObject/empty (0.00s)
    --- PASS: TestJSONObjectToYAMLObject/values (0.02s)
PASS
ok  	sigs.k8s.io/yaml	0.128s

@hakman
Copy link
Member

hakman commented Nov 12, 2020

@neolit123 maybe would help to add an ARM64 job for Travis.

@neolit123
Copy link
Member

maybe would help to add an ARM64 job for Travis.

yes, looks like someone tried to add ppc64le here:
#39

@hakman
Copy link
Member

hakman commented Nov 12, 2020

may be a bit simpler for ARM64 :)

@afbjorklund
Copy link

@neolit123 maybe would help to add an ARM64 job for Travis.

Maybe add ARM32 (arm a.k.a. armv7) as well, in that case ?

It had another one of those long-standing trivial bugs (#23)

@neolit123
Copy link
Member

@hakman
Copy link
Member

hakman commented Nov 13, 2020

@zhsj
Copy link
Author

zhsj commented Nov 13, 2020

Funny, the Graviton2 tests pass: https://travis-ci.org/github/kubernetes-sigs/yaml/builds/743332132.

It seems travis is booting an amd64 vm when it should be arm64-graviton2

https://travis-ci.org/github/kubernetes-sigs/yaml/jobs/743332141#L189

$ travis_setup_go
go version go1.15.5 linux/amd64

@zhsj
Copy link
Author

zhsj commented Nov 13, 2020

oh, travis says 'arm64-graviton2 available only on travis-ci.com'

@afbjorklund
Copy link

afbjorklund commented Nov 13, 2020

I don't see ARM32 support in TravisCI

Maybe it supports binfmt_misc ?

That's how I prefer to run it myself...

$ cat /proc/sys/fs/binfmt_misc/qemu-arm
enabled
interpreter /usr/bin/qemu-arm-static
flags: OCF
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff000000000000000000feffffff

So that I can test arm32/arm64 from laptop.

@zhsj
Copy link
Author

zhsj commented Nov 13, 2020

It should be ok to run arm32 on arm64 env. Just tell Go with GOARCH=arm.

@afbjorklund
Copy link

afbjorklund commented Nov 13, 2020

Or run it all from the same VM, perhaps ?

+ arch
x86_64
+ go test ./
ok  	sigs.k8s.io/yaml	0.004s
+ GOARCH=arm GOARM=7 go test -exec qemu-arm ./
ok  	sigs.k8s.io/yaml	0.132s
+ GOARCH=arm64 go test -exec qemu-aarch64 ./
ok  	sigs.k8s.io/yaml	0.155s

Hardware emulation only when needed...

Too bad that Travis gave up on containers :-(

@hakman
Copy link
Member

hakman commented Nov 13, 2020

oh, travis says 'arm64-graviton2 available only on travis-ci.com'

At least they could have failed the test... 😞
Btw, seems that travis-ci.org is going away soon:
https://docs.travis-ci.com/user/migrate/open-source-repository-migration/#q-what-will-happen-to-travis-ciorg-after-december-31st-2020

Or run it all from the same VM, perhaps ?

Will update the PR soon.

@afbjorklund
Copy link

Btw, seems that travis-ci.org is going away

Seems ominous... Same as Docker Hub, perhaps ?

Then again:

Testing your open source projects will always be free!

Seriously. Always. We like to think of it as our way of giving
back to a community that connects so many people.

@hakman
Copy link
Member

hakman commented Nov 13, 2020

Problem will be migrating. Not sure how would be done for the k8s repos and if Prow will be able to see job status.
kubernetes/test-infra#10423

@afbjorklund
Copy link

Minikube just stopped using Travis and moved to GitHub Actions instead. There's still some Jenkins around though.

@hakman
Copy link
Member

hakman commented Nov 13, 2020

The problem with GH actions is that there is no ARM support (yet). Other than that, it's a good call, considering that TravisCI rate limited the open source jobs.

@afbjorklund
Copy link

The problem with GH actions is that there is no ARM support (yet).

You can use external workers for that, in the meantime (or QEMU)

@hakman
Copy link
Member

hakman commented Nov 13, 2020

You can use external workers for that, in the meantime (or QEMU)

If I would do it for my company, external workers would be an option, but not here.
As for QEMU... it's better than nothing, but can't replace real hardware for anything serious. Also, tends to duplicate the work when some issue is discovered, because you have to double check on real hardware also.

@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hakman
Copy link
Member

hakman commented Dec 13, 2020

/remove-lifecycle rotten
/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Dec 13, 2020
@hakman
Copy link
Member

hakman commented Dec 13, 2020

/reopen

@k8s-ci-robot
Copy link

@hakman: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants