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?