Skip to content

Add tests for functions without end marker. NFC #1405

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

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions test/core/binary.wast
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,62 @@
"integer too large"
)

;; Function with missing end marker (between two functions)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\03\02\00\00" ;; Function section: 2 functions
"\0a\0c\02" ;; Code section: 2 functions
;; function 0
"\04\00" ;; Function size and local type count
"\41\01" ;; i32.const 1
"\1a" ;; drop
;; Missing end marker here
;; function 1
"\05\00" ;; Function size and local type count
"\41\01" ;; i32.const 1
"\1a" ;; drop
"\0b" ;; end
)
"END opcode expected"
)

;; Function with missing end marker (at EOF)
(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
"\0a\06\01" ;; Code section: 1 function
;; function 0
"\04\00" ;; Function size and local type count
"\41\01" ;; i32.const 1
"\1a" ;; drop
;; Missing end marker here
)
"unexpected end of section or function"
)

;; Function with missing end marker (at end of code sections)
(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
"\0a\06\01" ;; Code section: 1 function
;; function 0
"\04\00" ;; Function size and local type count
"\41\01" ;; i32.const 1
"\1a" ;; drop
;; Missing end marker here
"\0b\03\01\01\00" ;; Data section
)
;; The spec interpreter consumes the `\0b` (data section start) as an
;; END instruction (also happens to be `\0b`) and reports the code section as
;; being larger than declared.
"section size mismatch"
)

;; Unsigned LEB128 must not be overlong
(assert_malformed
Expand Down