<?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>252539</bug_id>
          
          <creation_ts>2023-02-18 17:04:33 -0800</creation_ts>
          <short_desc>[Wasm-GC] Bytecode dumper crashes when printing code with nested arrays</short_desc>
          <delta_ts>2023-02-21 16:11:19 -0800</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 Local 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>247394</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Chevalier">tjc</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1934943</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Chevalier">tjc</who>
    <bug_when>2023-02-18 17:04:33 -0800</bug_when>
    <thetext>Running the following test with the bytecode dumper enabled:

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

function module(bytes, valid = true) {
  let buffer = new ArrayBuffer(bytes.length);
  let view = new Uint8Array(buffer);
  for (let i = 0; i &lt; bytes.length; ++i) {
    view[i] = bytes.charCodeAt(i);
  }
  return new WebAssembly.Module(buffer);
}

function testArray() {
    let m = instantiate(`(module
  (type $bvec (array i8))
  (type $a (array (ref $bvec)))

  (func $new (export &quot;new&quot;) (result (ref $a))
   (array.new_canon $a (array.new_canon_default $bvec (i32.const 2)) (i32.const 42))))`);
}

testArray();
```

command line: `jsc  -m --useWebAssemblyTypedFunctionReferences\=true --useWebAssemblyGC\=true --dumpGeneratedWasmBytecodes=true test_array.js`

results in a crash:

```
&lt;?&gt;.wasm-function[0] : () -&gt; [Ref]
wasm size: 12 bytes
bytecode: 5 instructions (0 16-bit instructions, 1 32-bit instructions); 33 bytes; 0 parameter(s); 18 local(s); 20 callee register(s)
[   0] enter              
[   1] **array_new        dst:loc18, size:SHOULD NEVER BE REACHED
/home/tjc/WebKit/Source/JavaScriptCore/bytecode/BytecodeDumper.cpp(438) : WTF::CString JSC::Wasm::BytecodeDumper::formatConstant(JSC::Wasm::Type, uint64_t) const
Aborted (core dumped)
```

I have a fix for this, which I&apos;ll submit shortly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1934945</commentid>
    <comment_count>1</comment_count>
    <who name="Tim Chevalier">tjc</who>
    <bug_when>2023-02-18 17:11:38 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/10339</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1935648</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-02-21 16:10:15 -0800</bug_when>
    <thetext>Committed 260637@main (506f2789666c): &lt;https://commits.webkit.org/260637@main&gt;

Reviewed commits have been landed. Closing PR #10339 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1935650</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-02-21 16:11:19 -0800</bug_when>
    <thetext>&lt;rdar://problem/105750999&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>