Skip to content

Commit

Permalink
fuzz: adds a float<>int conversion case (#2032)
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake authored Feb 9, 2024
1 parent 85fabd8 commit 25cf3c0
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/integration_test/fuzzcases/fuzzcases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,3 +944,19 @@ func Test2017(t *testing.T) {
require.Contains(t, err.Error(), "integer divide by zero")
})
}

func Test2031(t *testing.T) {
if !platform.CompilerSupported() {
return
}
if runtime.GOARCH == "amd64" && runtime.GOOS == "darwin" {
t.Skip()
}
run(t, func(t *testing.T, r wazero.Runtime) {
mod, err := r.Instantiate(ctx, getWasmBinary(t, "2031"))
require.NoError(t, err)
res, err := mod.ExportedFunction("").Call(ctx, 0)
require.NoError(t, err)
require.Equal(t, []uint64{2139095040, 9218868437227405312}, res)
})
}
Binary file not shown.
251 changes: 251 additions & 0 deletions internal/integration_test/fuzzcases/testdata/2031.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
(module
(func (param i32) (result f32 f64)
i32.const 1
f32.convert_i32_s
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
i32.const 1
f64.convert_i32_s
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c3c7c7c7cp+968 (;=4441722447000897000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.a0a7c7c7c7c7cp-863 (;=0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002646371332579738;)
i64.const 0
i64.const 0
i64.const 0
i64.const 0
i64.const 0
i64.const 0
i32.const 0
f32.const -0x1.a3a3a2p+36 (;=-112646040000;)
f64.const -0x1.c41b44c4abff8p-791 (;=-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001356045409382692;)
f64.const 0x1.c7c7c7c7c7c3fp+968 (;=4441723041807626700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.const -0x1.658afep-39 (;=-0.0000000000025404954;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.79cb0d6961b45p+710 (;=7948973738950113000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const -0x1.f7c7c7c7c7c7cp-775 (;=-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009902723550684624;)
f32.demote_f64
f64.const 0x1.c7c7c7c3f7c7cp+968 (;=4441723039593109000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x0p+0 (;=0;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
f64.const 0x1.c7c7c7c7c7c7cp+968 (;=4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;)
f32.demote_f64
global.set $result1
global.get $result1
f64.promote_f32
global.set $result2
global.get $result2
local.get 0
i32.eqz
if
global.get $result1
global.get $result2
return
else
end

i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
global.get 1
global.set 1
global.get 1
global.set 1
global.get 1
global.set 1
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
global.get 1
i32.xor
global.set 1
global.get 0
i64.xor
global.set 0
global.get 0
i64.xor
global.set 0
global.get 0
i64.xor
global.set 0
global.get 0
i64.xor
global.set 0
global.get 0
i64.xor
global.set 0
global.get 0
i64.xor
global.set 0
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
i64.reinterpret_f64
global.get 0
i64.xor
global.set 0
i32.reinterpret_f32
global.get 1
i32.xor
global.set 1
unreachable
)
(global (;0;) (mut i64) i64.const 0)
(global (;2;) (mut i32) i32.const 0)
(global $result1 (mut f32) f32.const 0)
(global $result2 (mut f64) f64.const 0)
(global (mut f64) f64.const 0) ;; dummy
(export "" (func 0))
)

0 comments on commit 25cf3c0

Please sign in to comment.