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

Improve tests, fix reading of data segments #105

Merged
merged 11 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion tests/address.wast
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,3 @@

(assert_trap (invoke "64_bad" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "64_bad" (i32.const 1)) "out of bounds memory access")

117 changes: 117 additions & 0 deletions tests/align.wast
Original file line number Diff line number Diff line change
Expand Up @@ -864,3 +864,120 @@
(assert_trap (invoke "store" (i32.const 65532) (i64.const -1)) "out of bounds memory access")
;; No memory was changed
(assert_return (invoke "load" (i32.const 65532)) (i32.const 0))

;; Test invalid alignment values that may cause overflow when parsed.
;; These use the binary format, because it stores alignment as a base-2 exponent.

;; Signed 32-bit overflow
(assert_invalid
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\05\03\01\00\01" ;; Memory section: 1 memory
"\0a\0a\01" ;; Code section: 1 function

;; function 0
"\08\00"
"\41\00" ;; i32.const 0
"\28\1f\00" ;; i32.load offset=0 align=2**31
"\1a" ;; drop
"\0b" ;; end
)
"alignment must not be larger than natural"
)

;; Unsigned 32-bit overflow
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\05\03\01\00\01" ;; Memory section: 1 memory
"\0a\0a\01" ;; Code section: 1 function

;; function 0
"\08\00"
"\41\00" ;; i32.const 0
"\28\20\00" ;; i32.load offset=0 align=2**32
"\1a" ;; drop
"\0b" ;; end
)
"malformed memop flags"
)

;; 32-bit out of range
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\05\03\01\00\01" ;; Memory section: 1 memory
"\0a\0a\01" ;; Code section: 1 function

;; function 0
"\08\00"
"\41\00" ;; i32.const 0
"\28\21\00" ;; i32.load offset=0 align=2**33
"\1a" ;; drop
"\0b" ;; end
)
"malformed memop flags"
)

;; Signed 64-bit overflow
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\05\03\01\00\01" ;; Memory section: 1 memory
"\0a\0a\01" ;; Code section: 1 function

;; function 0
"\08\00"
"\41\00" ;; i32.const 0
"\28\3f\00" ;; i32.load offset=0 align=2**63
"\1a" ;; drop
"\0b" ;; end
)
"malformed memop flags"
)

;; Unsigned 64-bit overflow
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\05\03\01\00\01" ;; Memory section: 1 memory
"\0a\0a\01" ;; Code section: 1 function

;; function 0
"\08\00"
"\41\00" ;; i32.const 0
"\28\40\00" ;; i32.load offset=0 align=2**64
"\1a" ;; drop
"\0b" ;; end
)
"malformed memop flags"
)

;; 64-bit out of range
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\05\03\01\00\01" ;; Memory section: 1 memory
"\0a\0a\01" ;; Code section: 1 function

;; function 0
"\08\00"
"\41\00" ;; i32.const 0
"\28\41\00" ;; i32.load offset=0 align=2**65
"\1a" ;; drop
"\0b" ;; end
)
"malformed memop flags"
)
Loading
Loading