kubernetes-sigs / yaml

A better way to marshal and unmarshal YAML in Golang
Other
248 stars 75 forks source link

Int overflow on 32 bits arches #23

Open eclipseo opened 5 years ago

eclipseo commented 5 years ago

Golang 1.12.6 on i686 and armv7:

Testing    in: /builddir/build/BUILD/yaml-1.1.0/_build/src
         PATH: /builddir/build/BUILD/yaml-1.1.0/_build/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
       GOPATH: /builddir/build/BUILD/yaml-1.1.0/_build:/usr/share/gocode
  GO111MODULE: off
      command: go test -buildmode pie -compiler gc -ldflags "-X sigs.k8s.io/yaml/version=1.1.0 -extldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '"
      testing: sigs.k8s.io/yaml
sigs.k8s.io/yaml
FAIL    sigs.k8s.io/yaml [build failed]
BUILDSTDERR: # sigs.k8s.io/yaml [sigs.k8s.io/yaml.test]
BUILDSTDERR: ./yaml_test.go:22:26: constant 9223372036854775807 overflows int
fejta-bot commented 5 years ago

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

fejta-bot commented 5 years ago

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

neolit123 commented 5 years ago

/remove-lifecycle rotten @eclipseo would you be able to send a PR to fix this?

fejta-bot commented 4 years ago

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

fejta-bot commented 4 years ago

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

neolit123 commented 4 years ago

/lifecycle frozen

afbjorklund commented 3 years ago

@neolit123 : this seems to just be missing a cast, from constant int to int64 ?

diff --git a/yaml_test.go b/yaml_test.go
index a88cbf3..6a3a3ed 100644
--- a/yaml_test.go
+++ b/yaml_test.go
@@ -24,7 +24,7 @@ type MarshalTest struct {
 func TestMarshal(t *testing.T) {
    f32String := strconv.FormatFloat(math.MaxFloat32, 'g', -1, 32)
    s := MarshalTest{"a", math.MaxInt64, math.MaxFloat32}
-   e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", math.MaxInt64, f32String))
+   e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", int64(math.MaxInt64), f32String))

    y, err := Marshal(s)
    if err != nil {
 GOARCH=arm go test ./
ok      sigs.k8s.io/yaml    0.353s
neolit123 commented 3 years ago

e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", int64(math.MaxInt64), f32String))

yes, this cast is valid because the limits are untyped ints.