Skip to content

Segfault in ctor-eval when optimizing an imported table of funcrefs #8209

Description

@stevenfontanella

I ran the following example from main to see whether the no-op function call would get optimized away:

;; repro.wast
;; bin/wasm-ctor-eval --ctors=test repro.wast
(module
  (import "env" "table" (table $t 1 funcref))
  (type $v (func))
  (func $target (type $v)
    (nop)
  )
  (elem (table $t) (i32.const 0) func $target)

  (func $test
    (call_indirect $t (type $v) (i32.const 0))
  )
  (export "test" (func $test))
)

Unlike other similar issues, this one does import from env which is expected to work.

From checking lldb, the crash is from dereferencing null in tableSize: link. Maybe this is related to the comment immediately above?

Activity

  1. stevenfontanella commented on Jan 22, 2026

    @stevenfontanella
    MemberAuthor

    Fixed by #8194.

     bin/wasm-ctor-eval --ctors=test repro.wast -S -o repro-out.wast
      ...stopping since could not create module instance: Imported table access.

    FWIW the no-op function call is not optimized away:

    (module
     (type $v (func))
     (import "env" "table" (table $t 1 funcref))
     (elem $0 (i32.const 0) $target)
     (export "test" (func $test))
     (func $target
      (nop)
     )
     (func $test
      (call_indirect (type $v)
       (i32.const 0)
      )
     )
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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