<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>243265</bug_id>
          
          <creation_ts>2022-07-27 14:12:31 -0700</creation_ts>
          <short_desc>[WASM-Function-References] Assertion failure when a function returns (ref &lt;idx&gt;) to JS</short_desc>
          <delta_ts>2022-11-02 17:08:56 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebAssembly</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>247393</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Asumu Takikawa">asumu</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>saam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1887160</commentid>
    <comment_count>0</comment_count>
    <who name="Asumu Takikawa">asumu</who>
    <bug_when>2022-07-27 14:12:31 -0700</bug_when>
    <thetext>A test case like the following will currently raise an assertion error:

```
//@ runWebAssemblySuite(&quot;--useWebAssemblyTypedFunctionReferences=true&quot;, &quot;--useWebAssemblyGC=false&quot;)

import * as assert from &quot;../assert.js&quot;;
import { compile, instantiate } from &quot;./wast-wrapper.js&quot;;

let m1 = instantiate(`
  (module
    (type (func))
    (type (func (result (ref 0))))
    (elem declare funcref (ref.func 0))
    (func)
    (func (export &quot;f&quot;) (type 1) (ref.func 0))
  )
`);

instantiate(`
  (module
    (type (func))
    (type (func (result (ref 0))))
    (func (import &quot;m&quot; &quot;f&quot;) (type 1))
  )
`, { m: { f: m1.exports.f } });
```

This will instead raise a parse error if typed funcrefs are turned off (the default).

The assertion failure comes from a ref-with-index type not being supported in `WasmToJS.cpp` in processing the result of an exported Wasm function. I think it should be possible to support this case, it just requires checking if the type index points to a function signature or not. For non-function signatures, it should probably error for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888674</commentid>
    <comment_count>1</comment_count>
    <who name="Asumu Takikawa">asumu</who>
    <bug_when>2022-08-03 11:24:20 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/2983</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888707</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-08-03 14:13:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/98075013&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1893527</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-08-24 11:47:47 -0700</bug_when>
    <thetext>Committed 253734@main (0c946f31a451): &lt;https://commits.webkit.org/253734@main&gt;

Reviewed commits have been landed. Closing PR #2983 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>