<?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>293832</bug_id>
          
          <creation_ts>2025-05-30 15:00:20 -0700</creation_ts>
          <short_desc>Page using wasm-gc ref.test instruction crashes in iOS Safari</short_desc>
          <delta_ts>2025-06-05 14:43:30 -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>Safari 18</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 18</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>roberthoodchatham</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>keith_miller</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2120800</commentid>
    <comment_count>0</comment_count>
    <who name="">roberthoodchatham</who>
    <bug_when>2025-05-30 15:00:20 -0700</bug_when>
    <thetext>The following website fails to load in Safari in iOS. It loads fine in Safari on desktop and also in other browsers.
https://pyodide.org/en/0.27.1/console.html

It was fixed by adding these lines that avoid using ref.test in Safari iOS:
https://github.com/python/cpython/blob/main/Python/emscripten_trampoline.c#L74-L77

The version with the fix:
https://pyodide.org/en/0.27.3/console.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2120813</commentid>
    <comment_count>1</comment_count>
    <who name="">roberthoodchatham</who>
    <bug_when>2025-05-30 15:40:27 -0700</bug_when>
    <thetext>I can reproduce the problem</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2120815</commentid>
    <comment_count>2</comment_count>
    <who name="">roberthoodchatham</who>
    <bug_when>2025-05-30 15:46:56 -0700</bug_when>
    <thetext>Here&apos;s a minimalish reproducer:
```
&lt;!doctype html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot; /&gt;
  &lt;/head&gt;
&lt;body&gt;
    &lt;div&gt;
        Result is:
    &lt;/div&gt;
    &lt;div id=&quot;result&quot;&gt;

    &lt;/div&gt;
    &lt;script type=&quot;module&quot;&gt;
        function sleep(ms) {
            return new Promise(res =&gt; setTimeout(res, ms));
        }
        // Try to initialize countArgsFunc
        const code = new Uint8Array([
            0x00, 0x61, 0x73, 0x6d, // \0asm magic number
            0x01, 0x00, 0x00, 0x00, // version 1
            0x01, 0x1b, // Type section, body is 0x1b bytes
                0x05, // 6 entries
                0x60, 0x00, 0x01, 0x7f,                         // (type $type0 (func (param) (result i32)))
                0x60, 0x01, 0x7f, 0x01, 0x7f,                   // (type $type1 (func (param i32) (result i32)))
                0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f,             // (type $type2 (func (param i32 i32) (result i32)))
                0x60, 0x03, 0x7f, 0x7f, 0x7f, 0x01, 0x7f,       // (type $type3 (func (param i32 i32 i32) (result i32)))
                0x60, 0x01, 0x7f, 0x00,                         // (type $blocktype (func (param i32) (result)))
            0x02, 0x09, // Import section, 0x9 byte body
                0x01, // 1 import (table $funcs (import &quot;e&quot; &quot;t&quot;) 0 funcref)
                0x01, 0x65, // &quot;e&quot;
                0x01, 0x74, // &quot;t&quot;
                0x01,       // importing a table
                0x70,       // of entry type funcref
                0x00, 0x00, // table limits: no max, min of 0
            0x03, 0x02,   // Function section
                0x01, 0x01, // We&apos;re going to define one function of type 1 (func (param i32) (result i32))
            0x07, 0x05, // export section
                0x01, // 1 export
                0x01, 0x66, // called &quot;f&quot;
                0x00, // a function
                0x00, // at index 0

            0x0a, 0x44,  // Code section,
                0x01, 0x42, // one entry of length 50
                0x01, 0x01, 0x70, // one local of type funcref
                // Body of the function
                0x20, 0x00,       // local.get $fptr
                0x25, 0x00,       // table.get $funcs
                0x22, 0x01,       // local.tee $fref
                0xfb, 0x14, 0x03, // ref.test $type3
                0x02, 0x04,       // block $b (type $blocktype)
                    0x45,         //   i32.eqz
                    0x0d, 0x00,   //   br_if $b
                    0x41, 0x03,   //   i32.const 3
                    0x0f,         //   return
                0x0b,             // end block

                0x20, 0x01,       // local.get $fref
                0xfb, 0x14, 0x02, // ref.test $type2
                0x02, 0x04,       // block $b (type $blocktype)
                    0x45,         //   i32.eqz
                    0x0d, 0x00,   //   br_if $b
                    0x41, 0x02,   //   i32.const 2
                    0x0f,         //   return
                0x0b,             // end block

                0x20, 0x01,       // local.get $fref
                0xfb, 0x14, 0x01, // ref.test $type1
                0x02, 0x04,       // block $b (type $blocktype)
                    0x45,         //   i32.eqz
                    0x0d, 0x00,   //   br_if $b
                    0x41, 0x01,   //   i32.const 1
                    0x0f,         //   return
                0x0b,             // end block

                0x20, 0x01,       // local.get $fref
                0xfb, 0x14, 0x00, // ref.test $type0
                0x02, 0x04,       // block $b (type $blocktype)
                    0x45,         //   i32.eqz
                    0x0d, 0x00,   //   br_if $b
                    0x41, 0x00,   //   i32.const 0
                    0x0f,         //   return
                0x0b,             // end block

                0x41, 0x7f,       // i32.const -1
                0x0b // end function
        ]);
        const mod = new WebAssembly.Module(code);
        const wasmTable = new WebAssembly.Table({element: &quot;anyfunc&quot;, initial: 2});
        const inst = new WebAssembly.Instance(mod, { e: { t: wasmTable } });
        wasmTable.set(0, inst.exports.f);
        const f = inst.exports.f;
        for (let i = 0; i &lt; 10000; i++) {
            document.querySelector(&quot;#result&quot;).innerText = `${i}: ${f(0)}`;
            if (i % 1000 === 0) {
                await sleep(100);
            }
        }
    &lt;/script&gt;
&lt;/body&gt;
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2120816</commentid>
    <comment_count>3</comment_count>
    <who name="">roberthoodchatham</who>
    <bug_when>2025-05-30 15:49:03 -0700</bug_when>
    <thetext>Deployed this here:
https://wasm-gc-test.pages.dev/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2121988</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-06-05 13:51:53 -0700</bug_when>
    <thetext>Likely a dupe of bug 293113 :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2121989</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-06-05 13:51:59 -0700</bug_when>
    <thetext>&lt;rdar://problem/152674966&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2122008</commentid>
    <comment_count>6</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-06-05 14:42:49 -0700</bug_when>
    <thetext>Yes, it was a dupe.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2122009</commentid>
    <comment_count>7</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-06-05 14:42:52 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 293113 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2122011</commentid>
    <comment_count>8</comment_count>
    <who name="">roberthoodchatham</who>
    <bug_when>2025-06-05 14:43:30 -0700</bug_when>
    <thetext>Thanks!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>