From ddee8474668b9621820bca73b207abd5a0e9a62e Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 7 Feb 2018 20:26:18 +0300 Subject: [PATCH] wrong varuint1 case --- res/cases/v1/varuint1_1.wasm | Bin 0 -> 351 bytes res/cases/v1/varuint1_1.wat | 140 +++++++++++++++++++++++++++++++++++ src/elements/module.rs | 7 ++ 3 files changed, 147 insertions(+) create mode 100644 res/cases/v1/varuint1_1.wasm create mode 100644 res/cases/v1/varuint1_1.wat diff --git a/res/cases/v1/varuint1_1.wasm b/res/cases/v1/varuint1_1.wasm new file mode 100644 index 0000000000000000000000000000000000000000..c22ae5f66d30b573a847404d8255b32b68bed482 GIT binary patch literal 351 zcmY+AJ5Iw;5Jl(ueGne3ND)dw6%;RkC1eCHkk|o5Y#}}t#NrbgWcyj{Ak^ttMOqp* z!6s;^5b%tIY-YMM_ud%|Wp{HB5r#S?xRfYGg(^jfQW;GMls35b5~HC2YvCXvZ|ny4 z?7lde?GbHXWX1VWKF=42MZU|7wES-_>&t=VDI~cLN xuj(Xf_ckSSq}WK~I6?$wwj`lHdPrm6$GRGm+4r9#=Fu<8bm`GSi`w!I&<}ksKkfhk literal 0 HcmV?d00001 diff --git a/res/cases/v1/varuint1_1.wat b/res/cases/v1/varuint1_1.wat new file mode 100644 index 0000000..f072d1c --- /dev/null +++ b/res/cases/v1/varuint1_1.wat @@ -0,0 +1,140 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param f32) (result f32))) + (type (;3;) (func (param f64) (result f64))) + (func (;0;) (type 0) (result i32) + block ;; label = @1 + get_global 0 + i32.eqz + if ;; label = @2 + i32.const 1 + return + end + get_global 0 + i32.const 1 + i32.sub + set_global 0 + end + block (result i32) ;; label = @1 + nop + loop (result i32) ;; label = @2 + block ;; label = @3 + get_global 0 + i32.eqz + if ;; label = @4 + i32.const 36 + return + end + get_global 0 + i32.const 1 + i32.sub + set_global 0 + end + i32.const 1684958791 + i32.const 1 + i32.const -32768 + if (result i32) ;; label = @3 + loop (result i32) ;; label = @4 + block ;; label = @5 + get_global 0 + i32.eqz + if ;; label = @6 + i32.const -110 + return + end + get_global 0 + i32.const 1 + i32.sub + set_global 0 + end + i32.const -126 + loop (result i32) ;; label = @5 + block ;; label = @6 + get_global 0 + i32.eqz + if ;; label = @7 + i32.const -12743 + return + end + get_global 0 + i32.const 1 + i32.sub + set_global 0 + end + block (result i32) ;; label = @6 + block ;; label = @7 + nop + block (result i32) ;; label = @8 + nop + br 1 (;@7;) + end + i32.const 15 + i32.and + loop (result i32) ;; label = @8 + block ;; label = @9 + get_global 0 + i32.eqz + if ;; label = @10 + i32.const 1 + return + end + get_global 0 + i32.const 1 + i32.sub + set_global 0 + end + block (result i32) ;; label = @9 + i32.const 36 + end + end + i32.eqz + if (result i32) ;; label = @8 + i32.const -111 + else + i32.const -3899777 + end + i32.atomic.store16 offset=22 + end + i32.const -29071 + i32.eqz + br_if 1 (;@5;) + i32.const -8388608 + end + end + br_if 3 (;@1;) + end + else + i32.const -128 + end + br_if 1 (;@1;) + br_if 1 (;@1;) + end + end) + (func (;1;) (type 1) + i32.const 10 + set_global 0) + (func (;2;) (type 2) (param f32) (result f32) + get_local 0 + get_local 0 + f32.eq + if (result f32) ;; label = @1 + get_local 0 + else + f32.const 0x0p+0 (;=0;) + end) + (func (;3;) (type 3) (param f64) (result f64) + get_local 0 + get_local 0 + f64.eq + if (result f64) ;; label = @1 + get_local 0 + else + f64.const 0x0p+0 (;=0;) + end) + (table (;0;) 0 0 anyfunc) + (memory (;0;) 1 1 shared) + (global (;0;) (mut i32) (i32.const 10)) + (export "func_0" (func 0)) + (export "hangLimitInitializer" (func 1)) + (elem (i32.const 0))) diff --git a/src/elements/module.rs b/src/elements/module.rs index afb80fa..f2fbb8e 100644 --- a/src/elements/module.rs +++ b/src/elements/module.rs @@ -503,4 +503,11 @@ mod integration_tests { assert!(found_section, "Name section should be present in dedicated example"); } + + #[test] + #[should_panic] + fn wrong_varuint1_case() { + let module = deserialize_file("./res/cases/v1/varuint1_1.wasm") + .expect("Maybe shouldn't be deserialized"); + } }