Skip to content

Identical function types not merged #3989

Closed

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

  1. tlively commented on Jul 19, 2021

    @tlively
    Member

    Interesting find! I would expect issues like this with nominal typing enabled, but not with the default equirecursive typing. Will investigate.

  2. tlively commented on Apr 29, 2024

    @tlively
    Member

    This no longer seems to reproduce after switching to the new parser and making a bunch of other changes that might have been related.

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