<?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>233029</bug_id>
          
          <creation_ts>2021-11-11 22:35:51 -0800</creation_ts>
          <short_desc>crash in JSC::JSStringJoiner::append8Bit</short_desc>
          <delta_ts>2021-11-19 00:46:36 -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>JavaScriptCore</component>
          <version>WebKit Local Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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>zhunkibatu</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>fpizlo</cc>
    
    <cc>keith_miller</cc>
    
    <cc>rmorisset</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1814356</commentid>
    <comment_count>0</comment_count>
      <attachid>444048</attachid>
    <who name="">zhunkibatu</who>
    <bug_when>2021-11-11 22:35:51 -0800</bug_when>
    <thetext>Created attachment 444048
the minimal poc

the following poc can crash jsc.
#####################################################################

function test() {
    let maxSize = 0x10000;
	var memory = new WebAssembly.Memory({ initial: 0x100 });
	memory.grow(maxSize - 0x100);
	var result = String(new Uint8Array(memory.buffer));
}

test();

######################################################################

#0  WTF::Vector&lt;WTF::StringViewWithUnderlyingString, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;::uncheckedAppend&lt;WTF::StringViewWithUnderlyingString&gt; (value=..., this=0x7fffffffc5d8)
    at WTF/Headers/wtf/Vector.h:1391
#1  WTF::Vector&lt;WTF::StringViewWithUnderlyingString, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;::uncheckedAppend (value=..., this=0x7fffffffc5d8) at WTF/Headers/wtf/Vector.h:782
#2  JSC::JSStringJoiner::append8Bit (string=..., this=0x7fffffffc5c0)
    at ../../Source/JavaScriptCore/runtime/JSStringJoiner.h:91
#3  JSC::JSStringJoiner::appendNumber (value=&lt;optimized out&gt;, vm=..., this=0x7fffffffc5c0)
    at ../../Source/JavaScriptCore/runtime/JSStringJoiner.h:165
#4  JSC::JSStringJoiner::appendWithoutSideEffects (value=..., globalObject=&lt;optimized out&gt;, 
    this=0x7fffffffc5c0) at ../../Source/JavaScriptCore/runtime/JSStringJoiner.h:121
#5  JSC::JSStringJoiner::append (value=..., globalObject=&lt;optimized out&gt;, this=0x7fffffffc5c0)
    at ../../Source/JavaScriptCore/runtime/JSStringJoiner.h:154
#6  JSC::genericTypedArrayViewProtoFuncJoin&lt;JSC::JSGenericTypedArrayView&lt;JSC::Uint8Adaptor&gt; &gt;(JSC::VM&amp;, JSC::JSGlobalObject*, JSC::CallFrame*)::{lambda(WTF::StringView)#1}::operator()(WTF::StringView) const (this=this@entry=0x7fffffffc690, separator=...)
    at ../../Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:291
#7  0x00007ffff67456ab in JSC::genericTypedArrayViewProtoFuncJoin&lt;JSC::JSGenericTypedArrayView&lt;JSC::Uint8Adaptor&gt; &gt; (callFrame=0x7fffffffc6f0, globalObject=&lt;optimized out&gt;, vm=...)
    at WTF/Headers/wtf/text/StringView.h:340
#8  JSC::typedArrayViewProtoFuncJoin (globalObject=&lt;optimized out&gt;, callFrame=0x7fffffffc6f0)
    at ../../Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp:301
#9  0x00007ffff21b78b9 in vmEntryToNative ()
    at ../../Source/JavaScriptCore/llint/LowLevelInterpreter.cpp:536
#10 0x00007ffff514b9e0 in JSC::Interpreter::executeCall (this=&lt;optimized out&gt;, 
    lexicalGlobalObject=lexicalGlobalObject@entry=0x7fffae9f9068, function=&lt;optimized out&gt;, 
    callData=..., thisValue=..., args=...)
    at ../../Source/JavaScriptCore/runtime/NativeFunction.h:92
#11 0x00007ffff5da2e0a in JSC::call (globalObject=globalObject@entry=0x7fffae9f9068, 
    functionObject=..., functionObject@entry=..., callData=..., thisValue=..., thisValue@entry=..., 
    args=...) at ../../Source/JavaScriptCore/runtime/JSObject.h:1385
#12 0x00007ffff5d104c6 in JSC::arrayProtoFuncToString (globalObject=0x7fffae9f9068, 
    callFrame=&lt;optimized out&gt;) at ../../Source/JavaScriptCore/runtime/JSCJSValueInlines.h:462
#13 0x00007ffff21b78b9 in vmEntryToNative ()
    at ../../Source/JavaScriptCore/llint/LowLevelInterpreter.cpp:536
#14 0x00007ffff514b9e0 in JSC::Interpreter::executeCall (this=&lt;optimized out&gt;, 
    lexicalGlobalObject=lexicalGlobalObject@entry=0x7fffae9f9068, function=&lt;optimized out&gt;, 
    callData=..., thisValue=..., args=...)
    at ../../Source/JavaScriptCore/runtime/NativeFunction.h:92
#15 0x00007ffff5da2e0a in JSC::call (globalObject=globalObject@entry=0x7fffae9f9068, 
    functionObject=..., functionObject@entry=..., callData=..., thisValue=..., thisValue@entry=..., 
    args=...) at ../../Source/JavaScriptCore/runtime/JSObject.h:1385
#16 0x00007ffff6617216 in JSC::callToPrimitiveFunction&lt;(JSC::CachedSpecialPropertyKey)1&gt; (
    hint=JSC::PreferString, propertyName=..., object=&lt;optimized out&gt;, globalObject=&lt;optimized out&gt;)
    at ../../Source/JavaScriptCore/runtime/JSCJSValueInlines.h:462
#17 JSC::JSObject::ordinaryToPrimitive (this=&lt;optimized out&gt;, globalObject=&lt;optimized out&gt;, 
    hint=&lt;optimized out&gt;) at ../../Source/JavaScriptCore/runtime/JSObject.cpp:2326
#18 0x00007ffff662d27e in JSC::JSObject::toPrimitive (this=0x7fffef1c0c48, 
    globalObject=globalObject@entry=0x7fffae9f9068, 
    preferredType=preferredType@entry=JSC::PreferString)
    at ../../Source/JavaScriptCore/runtime/JSObject.cpp:2360
#19 0x00007ffff632c174 in JSC::JSValue::toStringSlowCase (this=this@entry=0x7fffffffcf98, 
--Type &lt;RET&gt; for more, q to quit, c to continue without paging--
    globalObject=0x7fffae9f9068, returnEmptyStringOnError=returnEmptyStringOnError@entry=true)
    at ../../Source/JavaScriptCore/runtime/JSObject.h:1385
#20 0x00007ffff6be94de in JSC::JSValue::toString (globalObject=&lt;optimized out&gt;, 
    this=&lt;optimized out&gt;) at ../../Source/JavaScriptCore/runtime/JSString.h:1060
#21 JSC::stringConstructor (argument=..., globalObject=&lt;optimized out&gt;)
    at ../../Source/JavaScriptCore/runtime/StringConstructor.cpp:158
#22 JSC::callStringConstructor (callFrame=&lt;optimized out&gt;, globalObject=&lt;optimized out&gt;)
    at ../../Source/JavaScriptCore/runtime/StringConstructor.cpp:166
#23 JSC::callStringConstructor (globalObject=&lt;optimized out&gt;, callFrame=&lt;optimized out&gt;)
    at ../../Source/JavaScriptCore/runtime/StringConstructor.cpp:161
#24 0x00007fffaf0ff027 in ?? ()
#25 0x00007fffffffd070 in ?? ()
#26 0x00007ffff21d443c in js_trampoline_op_call ()
    at ../../Source/JavaScriptCore/llint/LowLevelInterpreter.cpp:536
#27 0x0000000000000000 in ?? ()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1814675</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2021-11-12 16:18:41 -0800</bug_when>
    <thetext>I cannot reproduce this in jsc CLI with a recent-ish build. Perhaps already fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1816751</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-11-18 22:36:20 -0800</bug_when>
    <thetext>&lt;rdar://problem/85587371&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1816768</commentid>
    <comment_count>3</comment_count>
    <who name="">zhunkibatu</who>
    <bug_when>2021-11-19 00:46:36 -0800</bug_when>
    <thetext>I still can produce in latest build.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>444048</attachid>
            <date>2021-11-11 22:35:51 -0800</date>
            <delta_ts>2021-11-11 22:35:51 -0800</delta_ts>
            <desc>the minimal poc</desc>
            <filename>poc.js</filename>
            <type>text/javascript</type>
            <size>198</size>
            <attacher>zhunkibatu</attacher>
            
              <data encoding="base64">ZnVuY3Rpb24gdGVzdCgpIHsKICAgIGxldCBtYXhTaXplID0gMHgxMDAwMDsKCXZhciBtZW1vcnkg
PSBuZXcgV2ViQXNzZW1ibHkuTWVtb3J5KHsgaW5pdGlhbDogMHgxMDAgfSk7CgltZW1vcnkuZ3Jv
dyhtYXhTaXplIC0gMHgxMDApOwoJdmFyIHJlc3VsdCA9IFN0cmluZyhuZXcgVWludDhBcnJheSht
ZW1vcnkuYnVmZmVyKSk7Cn0KCnRlc3QoKTsK
</data>

          </attachment>
      

    </bug>

</bugzilla>