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

Fuzz bug: merge-similar-functions breaks validation #5580

Closed
tlively opened this issue Mar 16, 2023 · 2 comments · Fixed by #5581
Closed

Fuzz bug: merge-similar-functions breaks validation #5580

tlively opened this issue Mar 16, 2023 · 2 comments · Fixed by #5581
Assignees

Comments

@tlively
Copy link
Member

tlively commented Mar 16, 2023

The fuzzer found this test case:

(module
 (rec
  (type $none_=>_none (func))
  (type $i32_=>_none (func (param i32)))
 )
 (import "fuzzing-support" "log-i32" (func $fimport$0 (param i32)))
 (global $global$0 (mut i32) (i32.const 100))
 (export "func_227_invoker" (func $0))
 (export "func_94" (func $1))
 (export "func_360" (func $2))
 (export "func_319" (func $3))
 (func $0 (type $none_=>_none)
  (global.set $global$0
   (i32.const -1)
  )
  (global.set $global$0
   (i32.const -2)
  )
 )
 (func $1 (type $none_=>_none)
  (if
   (global.get $global$0)
   (unreachable)
  )
  (unreachable)
 )
 (func $2 (type $none_=>_none)
  (if
   (i32.eqz
    (global.get $global$0)
   )
   (block
    (global.set $global$0
     (i32.const 100)
    )
    (unreachable)
   )
  )
  (global.set $global$0
   (i32.sub
    (global.get $global$0)
    (i32.const 1)
   )
  )
  (call $fimport$0
   (i32.const 0)
  )
  (return_call $0)
 )
 (func $3 (type $none_=>_none)
  (if
   (i32.eqz
    (global.get $global$0)
   )
   (block
    (global.set $global$0
     (i32.const 100)
    )
    (unreachable)
   )
  )
  (global.set $global$0
   (i32.sub
    (global.get $global$0)
    (i32.const 1)
   )
  )
  (call $fimport$0
   (i32.const 0)
  )
  (return_call $1)
 )
)

Running wasm-opt -all a.wast --merge-similar-functions produces this error:

[wasm-validator error in function byn$mgfn-shared$2] unexpected false: unreachable instruction must have unreachable child, on
(call_ref $none_=>_none
 (local.get $0)
)
Fatal: error after opts
@kripken
Copy link
Member

kripken commented Mar 16, 2023

Looks like a bad copy-paste here perhaps? Some functions appear twice, and function $2 has one definition without a body (only (func $2 (type $none_=>_none) with no closing paren after it).

Also (type $i32_=>_none (func (param i32))) appears twice, which I think is #3989 which is why RoundTripText is disabled in the fuzzer atm (as a workaround, --name-types fixes it).

@tlively
Copy link
Member Author

tlively commented Mar 16, 2023

Yep, bad copy-paste, sorry. I've edited the comment so it should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants