Skip to content

Identical function types not merged #3989

Description

@kripken

STR: wasm-opt w.wasm -all --print --name-types --print

The output is

(module
 (type $none_=>_none (func))
 (global $global$0 (ref null $none_=>_none) (ref.func $0))
 (global $global$1 i32 (i32.const 0))
 (global $global$2 (mut externref) (ref.null extern))
 (global $global$3 (mut i32) (i32.const -6567))
 (global $global$4 (mut anyref) (ref.null any))
 (global $global$5 (mut i32) (i32.const 10))
 (memory $0 (shared 16 17))
 (table $0 16 funcref)
 (table $1 28 funcref)
 (table $2 18 18 funcref)
 (table $3 0 0 externref)
 (elem $0 (table $0) (i32.const 0) func)
 (elem $1 (table $1) (i32.const 0) func)
 (elem $2 (table $1) (i32.const 1) func)
 (elem $3 (table $2) (i32.const 0) func)
 (elem $4 (table $2) (i32.const 2) func)
 (elem $5 func)
 (elem $6 func)
 (elem $7 (ref null $none_=>_none) (ref.func $0) (ref.func $0) (ref.null $none_=>_none))
 (elem $8 func)
 (func $0
  (nop)
 )
)
(module
 (type $type$0 (func))
 (global $global$0 (ref null $type$0) (ref.func $0))
 (global $global$1 i32 (i32.const 0))
 (global $global$2 (mut externref) (ref.null extern))
 (global $global$3 (mut i32) (i32.const -6567))
 (global $global$4 (mut anyref) (ref.null any))
 (global $global$5 (mut i32) (i32.const 10))
 (memory $0 (shared 16 17))
 (table $0 16 funcref)
 (table $1 28 funcref)
 (table $2 18 18 funcref)
 (table $3 0 0 externref)
 (elem $0 (table $0) (i32.const 0) func)
 (elem $1 (table $1) (i32.const 0) func)
 (elem $2 (table $1) (i32.const 1) func)
 (elem $3 (table $2) (i32.const 0) func)
 (elem $4 (table $2) (i32.const 2) func)
 (elem $5 func)
 (elem $6 func)
 (elem $7 (ref null $type$0) (ref.func $0) (ref.func $0) (ref.null $none_=>_none))
 (elem $8 func)
 (func $0
  (nop)
 )
)

The key thing is the $none_=>_none type, which should not exist after we name the types. It appears twice in the element segments, and remains in one of them at the end. It seems that the two may have gotten different types..?

cc @tlively

(found by fuzzer seed 9943180413750209438, then reduced. it can't be reduced by hand as the bug does not show itself on the text format...)

w.wasm.gz

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions