<?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>274052</bug_id>
          
          <creation_ts>2024-05-12 04:22:13 -0700</creation_ts>
          <short_desc>[JSC] Add JSString::resolveRopeWithoutGC and use it in GC end phase</short_desc>
          <delta_ts>2024-06-20 23:32:29 -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>JavaScriptCore</component>
          <version>WebKit Local Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Linux</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 name="qbtly">qbtly201</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>mark.lam</cc>
    
    <cc>nth10sd</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2034769</commentid>
    <comment_count>0</comment_count>
      <attachid>471376</attachid>
    <who name="qbtly">qbtly201</who>
    <bug_when>2024-05-12 04:22:13 -0700</bug_when>
    <thetext>Created attachment 471376
original_poc

###### Webkit
af7bd70a44bb1e3adae77f36bcc34a47daeeb9a4

###### Build platform
Ubuntu 22.04.3

###### Build steps
./Tools/Scripts/build-jsc --jsc-only --debug --build-dir=0512 --cmakeargs=&quot;-DENABLE_STATIC_JSC=ON&quot;
    	
###### Test case
```
function main() {
    error = (new Function(`return (function () { arguments.callee.displayName = &apos;a&apos;.repeat(0x100000) + &apos;b&apos;; `.repeat(100) + `return new Error();` + ` })();`.repeat(100)))();
    main.apply();
}
main();
```

###### Execution steps
./jsc poc.js

###### Output

ASSERTION FAILED: isMarked(cell)
../../../Source/JavaScriptCore/heap/Heap.cpp(615) : void JSC::Heap::reportExtraMemoryAllocatedPossiblyFromAlreadyMarkedCell(const JSC::JSCell *, size_t)

Thread 1 &quot;jsc&quot; received signal SIGABRT, Aborted.

pwndbg&gt; bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff5aa3859 in __GI_abort () at abort.c:79
#2  0x000000000042777a in WTFCrashWithInfo () at WTF/Headers/wtf/Assertions.h:846
#3  0x00000000013804a0 in JSC::Heap::reportExtraMemoryAllocatedPossiblyFromAlreadyMarkedCell (this=this@entry=0x7fffa90000c8, cell=&lt;optimized out&gt;, cell@entry=0x7fffa94d94a0, size=&lt;optimized out&gt;, size@entry=1048577) at ../../../Source/JavaScriptCore/heap/Heap.cpp:615
#4  0x0000000001380828 in JSC::Heap::reportExtraMemoryAllocatedSlowCase (this=0x7fffa90000c8, deferralContext=0x0, cell=0x7fffa94d94a0, size=1048577) at ../../../Source/JavaScriptCore/heap/Heap.cpp:630
#5  0x0000000001c6a7da in JSC::Heap::reportExtraMemoryAllocated (this=0x7fffa90000c8, cell=0x7fffa94d94a0, size=1048577) at ../../../Source/JavaScriptCore/heap/HeapInlines.h:216
#6  JSC::JSRopeString::resolveRopeWithFunction&lt;JSC::JSRopeString::resolveRope(JSC::JSGlobalObject*) const::$_3&gt;(JSC::JSGlobalObject*, JSC::JSRopeString::resolveRope(JSC::JSGlobalObject*) const::$_3&amp;&amp;) const (this=0x7fffa94d94a0, nullOrGlobalObjectForOOM=&lt;optimized out&gt;, function=...) at ../../../Source/JavaScriptCore/runtime/JSString.cpp:249
#7  JSC::JSRopeString::resolveRope (this=0x7fffa94d94a0, nullOrGlobalObjectForOOM=&lt;optimized out&gt;) at ../../../Source/JavaScriptCore/runtime/JSString.cpp:270
#8  0x0000000001b18fa2 in JSC::JSString::tryGetValue (this=0x7fffa94d94a0, allocationAllowed=true) at ../../../Source/JavaScriptCore/runtime/JSString.h:889
#9  JSC::getCalculatedDisplayName (vm=..., object=object@entry=0x7fffa947b440) at ../../../Source/JavaScriptCore/runtime/JSFunction.cpp:496
#10 0x0000000001eab3ff in JSC::StackFrame::functionName (this=&lt;optimized out&gt;, this@entry=0x7fffa95409b0, vm=...) at ../../../Source/JavaScriptCore/runtime/StackFrame.cpp:125
#11 0x0000000001eab881 in JSC::StackFrame::toString (this=0x7fffa95409b0, vm=...) at ../../../Source/JavaScriptCore/runtime/StackFrame.cpp:154
#12 0x00000000014d3067 in JSC::Interpreter::stackTraceAsString (vm=..., stackTrace=...) at ../../../Source/JavaScriptCore/interpreter/Interpreter.cpp:548
#13 0x00000000019b67ef in JSC::ErrorInstance::computeErrorInfo (this=0x7fffeb0384d8, vm=...) at ../../../Source/JavaScriptCore/runtime/ErrorInstance.cpp:266
#14 0x0000000001383588 in JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1}::operator()(JSC::HeapCell*, JSC::HeapCell::Kind) const (this=&lt;optimized out&gt;, cell=0x2, cell@entry=0x7fffa9000000) at ../../../Source/JavaScriptCore/heap/Heap.cpp:712
#15 JSC::Subspace::forEachMarkedCell&lt;JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1}&gt;(JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1} const&amp;)::{lambda(JSC::PreciseAllocation*)#1}::operator()(JSC::PreciseAllocation*) const (this=&lt;optimized out&gt;, allocation=0x7fffeb038468) at ../../../Source/JavaScriptCore/heap/SubspaceInlines.h:84
#16 JSC::Subspace::forEachPreciseAllocation&lt;JSC::Subspace::forEachMarkedCell&lt;JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1}&gt;(JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1} const&amp;)::{lambda(JSC::PreciseAllocation*)#1}&gt;(JSC::Subspace::forEachMarkedCell&lt;JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1}&gt;(JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1} const&amp;)::{lambda(JSC::PreciseAllocation*)#1} const&amp;) (this=&lt;optimized out&gt;, func=...) at ../../../Source/JavaScriptCore/heap/SubspaceInlines.h:66
#17 JSC::Subspace::forEachMarkedCell&lt;JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1}&gt;(JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt;(JSC::IsoSubspace&amp;, JSC::CollectionScope)::{lambda(JSC::HeapCell*, JSC::HeapCell::Kind)#1} const&amp;) (this=&lt;optimized out&gt;, func=...) at ../../../Source/JavaScriptCore/heap/SubspaceInlines.h:81
#18 JSC::Heap::finalizeMarkedUnconditionalFinalizers&lt;JSC::ErrorInstance, JSC::IsoSubspace&gt; (this=0x7fffa90000c8, cellSet=..., collectionScope=&lt;optimized out&gt;) at ../../../Source/JavaScriptCore/heap/Heap.cpp:710
#19 JSC::Heap::finalizeUnconditionalFinalizers (this=this@entry=0x7fffa90000c8) at ../../../Source/JavaScriptCore/heap/Heap.cpp:752
#20 0x000000000138e6aa in JSC::Heap::runEndPhase (this=&lt;optimized out&gt;, this@entry=0x7fffa90000c8, conn=JSC::GCConductor::Mutator) at ../../../Source/JavaScriptCore/heap/Heap.cpp:1667
#21 0x000000000138b308 in JSC::Heap::runCurrentPhase (this=this@entry=0x7fffa90000c8, conn=conn@entry=JSC::GCConductor::Mutator, currentThreadState=currentThreadState@entry=0x7fffffffcb00) at ../../../Source/JavaScriptCore/heap/Heap.cpp:1372
#22 0x00000000013d0edd in JSC::Heap::collectInMutatorThread()::$_0::operator()(JSC::CurrentThreadState&amp;) const (this=&lt;optimized out&gt;, state=...) at ../../../Source/JavaScriptCore/heap/Heap.cpp:1993
#23 WTF::ScopedLambdaFunctor&lt;void (JSC::CurrentThreadState&amp;), JSC::Heap::collectInMutatorThread()::$_0&gt;::implFunction(void*, JSC::CurrentThreadState&amp;) (argument=&lt;optimized out&gt;, arguments=...) at WTF/Headers/wtf/ScopedLambda.h:106
#24 0x0000000001418149 in WTF::ScopedLambda&lt;void (JSC::CurrentThreadState&amp;)&gt;::operator()&lt;JSC::CurrentThreadState&amp;&gt;(JSC::CurrentThreadState&amp;) const (this=0x7fffffffcb68, arguments=...) at WTF/Headers/wtf/ScopedLambda.h:58
#25 JSC::callWithCurrentThreadState(WTF::ScopedLambda&lt;void (JSC::CurrentThreadState&amp;)&gt; const&amp;) (lambda=...) at ../../../Source/JavaScriptCore/heap/MachineStackMarker.cpp:227
#26 0x0000000001393977 in JSC::Heap::collectInMutatorThread (this=this@entry=0x7fffa90000c8) at ../../../Source/JavaScriptCore/heap/Heap.cpp:2005
#27 0x0000000001393724 in JSC::Heap::stopIfNecessarySlow (this=this@entry=0x7fffa90000c8, oldState=5) at ../../../Source/JavaScriptCore/heap/Heap.cpp:1974
#28 0x00000000013935be in JSC::Heap::stopIfNecessarySlow (this=0x7fffa90000c8) at ../../../Source/JavaScriptCore/heap/Heap.cpp:1946
#29 0x000000000043646d in JSC::JSString::create (vm=..., value=...) at ../../../Source/JavaScriptCore/runtime/JSString.h:194
#30 0x0000000000ca14a9 in JSC::jsString (vm=..., s=...) at ../../../Source/JavaScriptCore/runtime/JSString.h:927
#31 JSC::jsString (vm=..., s=...) at ../../../Source/JavaScriptCore/runtime/JSString.h:965
#32 0x00000000018a870e in JSC::repeatCharacter&lt;unsigned char&gt; (globalObject=globalObject@entry=0x7fffa941a088, character=97 &apos;a&apos;, repeatCount=repeatCount@entry=1048576) at ../../../Source/JavaScriptCore/runtime/JSStringInlines.h:107
#33 0x0000000001ec83c1 in JSC::stringProtoFuncRepeatCharacter (globalObject=0x7fffa941a088, callFrame=0x7fffffffce10) at ../../../Source/JavaScriptCore/runtime/StringPrototype.cpp:867
#34 0x00007fffaac216a6 in ?? ()
#35 0x00007fffffffcea0 in ?? ()
#36 0x0000000002533bee in llint_op_call ()
#37 0x0000000000000000 in ?? ()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2034975</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-05-13 10:10:36 -0700</bug_when>
    <thetext>&lt;rdar://problem/128009982&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2042349</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2024-06-20 17:16:41 -0700</bug_when>
    <thetext>Yeah, this does not actually become a problem since it just increment external memory count (not actually allocating GC memory). So, handling as a normal crash issue on debug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2042350</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2024-06-20 17:25:23 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/30028</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2042385</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-06-20 23:32:27 -0700</bug_when>
    <thetext>Committed 280239@main (68768cee2adf): &lt;https://commits.webkit.org/280239@main&gt;

Reviewed commits have been landed. Closing PR #30028 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>471376</attachid>
            <date>2024-05-12 04:22:13 -0700</date>
            <delta_ts>2024-05-12 04:22:13 -0700</delta_ts>
            <desc>original_poc</desc>
            <filename>original_poc.js</filename>
            <type>text/javascript</type>
            <size>476</size>
            <attacher name="qbtly">qbtly201</attacher>
            
              <data encoding="base64">Y29uc3QgTlVNX05FU1RFRF9GVU5DVElPTlMgPSAxMDA7CgpmdW5jdGlvbiBtYWluKCkgewogICAg
Y29uc3QgZXJyb3IgPSAobmV3IEZ1bmN0aW9uKGByZXR1cm4gKGZ1bmN0aW9uICgpIHsgYXJndW1l
bnRzLmNhbGxlZS5kaXNwbGF5TmFtZSA9ICdhJy5yZXBlYXQoMHgxMDAwMDApICsgJ2InOyBgLnJl
cGVhdChOVU1fTkVTVEVEX0ZVTkNUSU9OUykgKyBgcmV0dXJuIG5ldyBFcnJvcigpO2AgKyBgIH0p
KCk7YC5yZXBlYXQoTlVNX05FU1RFRF9GVU5DVElPTlMpKSkoKTsKbGV0IHpkeTAgPSBtYWluLmFw
cGx5KG1haW4sIFtbXSwgWzYzLCB7J2wnOiAnR3c2OUsnLCAndic6IC05MDA3MTk5MjU0NzQwOTkw
LCAndCc6ICdJbycsICdiJzogJ0RYOEUnfSwgLTAuMCwgLTIwLjk3MDc4NTM5NDU3NzgwMywgLTE4
LCAnY05MNW4nLCAtMl0sICdhT05rMEVYJywgLTgyLCAndHZtTWQ1ZGNiTSddKTsKCgogICAgZXJy
b3Iuc3RhY2s7Cn0KCm1haW4oKTs=
</data>

          </attachment>
      

    </bug>

</bugzilla>