Skip to content

Fuzz bug with DCE on pop moved into block in old EH #6918

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

Closed
kripken opened this issue Sep 9, 2024 · 0 comments · Fixed by #6922
Closed

Fuzz bug with DCE on pop moved into block in old EH #6918

kripken opened this issue Sep 9, 2024 · 0 comments · Fixed by #6922
Assignees

Comments

@kripken
Copy link
Member

kripken commented Sep 9, 2024

(module
 (type $struct (struct (field (mut (ref null eq)))))

 (tag $tag (param (ref null eq)))

 (func $0 (result i32)
  (try (result i32)
   (do
    (i32.const 0)
   )
   (catch $tag
    (drop
     (ref.eq
      (struct.new $struct
       (pop (ref null eq))
      )
      (unreachable)
     )
    )
    (i32.const 0)
   )
   (catch_all
    (i32.const 0)
   )
  )
 )
)
$ bin/wasm-opt a.wat -all --dce 
[wasm-validator error in function 0] unexpected false: , on 
(try (result i32)
 (do
  (i32.const 0)
 )
 (catch $tag
  (block
   (drop
    (struct.new $struct
     (pop eqref)
    )
   )
   (unreachable)
  )
 )
 (catch_all
  (i32.const 0)
 )
)
catch's body (tag)'s pop's location is not validFatal: error after opts

cc @aheejin

@aheejin aheejin self-assigned this Sep 10, 2024
aheejin added a commit to aheejin/binaryen that referenced this issue Sep 10, 2024
 WebAssembly#6400 fixed this case but that handled only when a `pop` is an
immediate child of the current expression, but a `pop` can be nested
deeper down.

Fixes WebAssembly#6918.
aheejin added a commit that referenced this issue Sep 11, 2024
#6400 fixed this case but that handled only when a `pop` is an
immediate child of the current expression, but a `pop` can be nested
deeper down.

We conservatively run the EH fixup whenever we have a `pop` and create
`block`s in the optimization. We considered using `FindAll<Pop>` to make
it precise, but we decided the quadratic time plexity was not worth it.

Fixes #6918.
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