<?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>227765</bug_id>
          
          <creation_ts>2021-07-07 12:53:05 -0700</creation_ts>
          <short_desc>JSArrayBufferView::byteOffsetConcurrently has a race when using PAC</short_desc>
          <delta_ts>2021-07-07 19:21:17 -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 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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Saam Barati">saam</reporter>
          <assigned_to name="Saam Barati">saam</assigned_to>
          <cc>ews-watchlist</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>tzagallo</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1775405</commentid>
    <comment_count>0</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2021-07-07 12:53:05 -0700</bug_when>
    <thetext>Compiler thread crash.

stress/JSArrayBufferView-byteOffset-is-racy-from-compiler-thread.js.default: test_script_20: line 2: 77566 Trace/BPT trap: 5       ( &quot;$@&quot; ../../.vm/JavaScriptCore.framework/Helpers/jsc --useFTLJIT\=false --useFunctionDotArguments\=true --validateExceptionChecks\=true --useDollarVM\=true --maxPerThreadStackUsage\=1572864 --useFTLJIT\=true --jitPolicyScale\=0 JSArrayBufferView-byteOffset-is-racy-from-compiler-thread.js )




Exception Type:        EXC_BREAKPOINT (SIGTRAP)


Thread 3 Crashed:: JIT Worklist Helper Thread
0   JavaScriptCore                	       0x102aa03ec void* WTF::untagArrayPtr&lt;void&gt;(void*, unsigned long) + 20 (PtrTag.h:438) [inlined]
1   JavaScriptCore                	       0x102aa03ec WTF::CagedPtr&lt;(Gigacage::Kind)0, void, true, WTF::RawPtrTraits&lt;void&gt; &gt;::getMayBeNull(unsigned long) const + 92 (CagedPtr.h:75) [inlined]
2   JavaScriptCore                	       0x102aa03ec JSC::CagedBarrierPtr&lt;(Gigacage::Kind)0, void, true&gt;::getMayBeNull(unsigned long) const + 92 (CagedBarrierPtr.h:62) [inlined]
3   JavaScriptCore                	       0x102aa03ec JSC::JSArrayBufferView::vector() const + 120 (JSArrayBufferView.h:190) [inlined]
4   JavaScriptCore                	       0x102aa03ec std::__1::optional&lt;unsigned int&gt; JSC::JSArrayBufferView::byteOffsetImpl&lt;(JSC::JSArrayBufferView::Requester)1, std::__1::optional&lt;unsigned int&gt; &gt;() + 132 (JSArrayBufferViewInlines.h:100) [inlined]
5   JavaScriptCore                	       0x102aa03ec JSC::JSArrayBufferView::byteOffsetConcurrently() + 132 (JSArrayBufferViewInlines.h:120) [inlined]
6   JavaScriptCore                	       0x102aa03ec JSC::DFG::AbstractInterpreter&lt;JSC::DFG::InPlaceAbstractState&gt;::executeEffects(unsigned int, JSC::DFG::Node*) + 53252 (DFGAbstractInterpreterInlines.h:3802)
7   JavaScriptCore                	       0x102a9c714 JSC::DFG::AbstractInterpreter&lt;JSC::DFG::InPlaceAbstractState&gt;::executeEffects(unsigned int, JSC::DFG::Node*) + 37676 (DFGAbstractInterpreterInlines.h:3800)
8   JavaScriptCore                	       0x10305701c JSC::DFG::AbstractInterpreter&lt;JSC::DFG::InPlaceAbstractState&gt;::execute(unsigned int) + 60 (DFGAbstractInterpreterInlines.h:4681) [inlined]
9   JavaScriptCore                	       0x10305701c JSC::DFG::CFAPhase::performBlockCFA(JSC::DFG::BasicBlock*) + 544 (DFGCFAPhase.cpp:232)
10  JavaScriptCore                	       0x103056904 JSC::DFG::CFAPhase::performForwardCFA() + 64 (DFGCFAPhase.cpp:263) [inlined]
11  JavaScriptCore                	       0x103056904 JSC::DFG::CFAPhase::run() + 480 (DFGCFAPhase.cpp:119)
12  JavaScriptCore                	       0x1030565c4 bool JSC::DFG::runAndLog&lt;JSC::DFG::CFAPhase&gt;(JSC::DFG::CFAPhase&amp;) + 52 (DFGPhase.h:84)
13  JavaScriptCore                	       0x1030404b4 bool JSC::DFG::runPhase&lt;JSC::DFG::CFAPhase&gt;(JSC::DFG::Graph&amp;) + 40 (DFGPhase.h:95)
14  JavaScriptCore                	       0x10318a7a8 JSC::DFG::Plan::compileInThreadImpl() + 1892 (DFGPlan.cpp:276)
15  JavaScriptCore                	       0x10342d454 JSC::JITPlan::compileInThread(JSC::JITWorklistThread*) + 452 (JITPlan.cpp:165)
16  JavaScriptCore                	       0x103474750 JSC::JITWorklistThread::work() + 252 (JITWorklistThread.cpp:123)
17  JavaScriptCore                	       0x10291dda8 WTF::AutomaticThread::start(WTF::AbstractLocker const&amp;)::$_0::operator()() const + 528 (AutomaticThread.cpp:229) [inlined]
18  JavaScriptCore                	       0x10291dda8 WTF::Detail::CallableWrapper&lt;WTF::AutomaticThread::start(WTF::AbstractLocker const&amp;)::$_0, void&gt;::call() + 568 (Function.h:53)
19  JavaScriptCore                	       0x1029688cc WTF::Function&lt;void ()&gt;::operator()() const + 60 (Function.h:82) [inlined]
20  JavaScriptCore                	       0x1029688cc WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*) + 184 (Threading.cpp:186)
21  JavaScriptCore                	       0x10296acd4 WTF::wtfThreadEntryPoint(void*) + 16 (ThreadingPOSIX.cpp:241)
22  libsystem_pthread.dylib       	       0x18d80543c _pthread_start + 148
23  libsystem_pthread.dylib       	       0x18d8000d4 thread_start + 8</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775423</commentid>
    <comment_count>1</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2021-07-07 13:32:47 -0700</bug_when>
    <thetext>Seems like the bug is in:
    inline std::optional&lt;unsigned&gt; byteOffsetConcurrently();


My guess is we&apos;re detaching concurrently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775424</commentid>
    <comment_count>2</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2021-07-07 13:33:33 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #1)
&gt; Seems like the bug is in:
&gt;     inline std::optional&lt;unsigned&gt; byteOffsetConcurrently();
&gt; 
&gt; 
&gt; My guess is we&apos;re detaching concurrently.

yeah, looks like that&apos;s what the test is doing:

//@ slow!
//@ runDefault(&quot;--jitPolicyScale=0&quot;)

// This test should not crash.

script = `
    let a = new Int32Array(1);
    for (let i = 0; i &lt; 1000; ++i)
        ~a.byteOffset;

    transferArrayBuffer(a.buffer);

    eval(a.byteOffset);
    let description = describe(a.byteOffset);
    if (description !== &apos;Int32: 0&apos;)
        print(description);
`;

const iterations = 1000;
for (let i = 0; i &lt; iterations; i++)
    runString(script);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775427</commentid>
    <comment_count>3</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2021-07-07 13:37:16 -0700</bug_when>
    <thetext>I think the fix is to have a different version of vector() for when run from the concurrent thread.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775548</commentid>
    <comment_count>4</comment_count>
      <attachid>433100</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2021-07-07 17:44:02 -0700</bug_when>
    <thetext>Created attachment 433100
patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775549</commentid>
    <comment_count>5</comment_count>
      <attachid>433100</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2021-07-07 17:46:43 -0700</bug_when>
    <thetext>Comment on attachment 433100
patch

r=me.  Is there anyway to assert that vectorWithoutPACValidation() is not called by the mutator?  Maybe not.  Just thought I&apos;d ask.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775554</commentid>
    <comment_count>6</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2021-07-07 17:55:29 -0700</bug_when>
    <thetext>(In reply to Mark Lam from comment #5)
&gt; Comment on attachment 433100 [details]
&gt; patch
&gt; 
&gt; r=me.  Is there anyway to assert that vectorWithoutPACValidation() is not
&gt; called by the mutator?  Maybe not.  Just thought I&apos;d ask.

This patch is making it so that vectorWithoutPACValidation is called on the mutator. So asserting would immediately crash. This patch aligns what the mutator thread already does when inlined in DFG/FTL&apos;s byte offset implementation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775582</commentid>
    <comment_count>7</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2021-07-07 19:20:58 -0700</bug_when>
    <thetext>Committed r279707 (239499@main): &lt;https://commits.webkit.org/239499@main&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 433100.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775583</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-07-07 19:21:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/80301239&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>433100</attachid>
            <date>2021-07-07 17:44:02 -0700</date>
            <delta_ts>2021-07-07 19:20:59 -0700</delta_ts>
            <desc>patch</desc>
            <filename>b-backup.diff</filename>
            <type>text/plain</type>
            <size>2296</size>
            <attacher name="Saam Barati">saam</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09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ZmZlclZpZXdJbmxpbmVzLmgK
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PQotLS0gU291cmNlL0phdmFTY3JpcHRDb3JlL3J1bnRpbWUvSlNBcnJheUJ1ZmZl
clZpZXdJbmxpbmVzLmgJKHJldmlzaW9uIDI3OTY2MikKKysrIFNvdXJjZS9KYXZhU2NyaXB0Q29y
ZS9ydW50aW1lL0pTQXJyYXlCdWZmZXJWaWV3SW5saW5lcy5oCSh3b3JraW5nIGNvcHkpCkBAIC05
Nyw3ICs5Nyw3IEBAIGlubGluZSBSZXN1bHRUeXBlIEpTQXJyYXlCdWZmZXJWaWV3OjpieXQKICAg
ICB9CiAKICAgICBwdHJkaWZmX3QgZGVsdGEgPQotICAgICAgICBiaXR3aXNlX2Nhc3Q8dWludDhf
dCo+KHZlY3RvcigpKSAtIHN0YXRpY19jYXN0PHVpbnQ4X3QqPihidWZmZXItPmRhdGEoKSk7Cisg
ICAgICAgIGJpdHdpc2VfY2FzdDx1aW50OF90Kj4odmVjdG9yV2l0aG91dFBBQ1ZhbGlkYXRpb24o
KSkgLSBzdGF0aWNfY2FzdDx1aW50OF90Kj4oYnVmZmVyLT5kYXRhKCkpOwogCiAgICAgdW5zaWdu
ZWQgcmVzdWx0ID0gc3RhdGljX2Nhc3Q8dW5zaWduZWQ+KGRlbHRhKTsKICAgICBpZiAocmVxdWVz
dGVyID09IE11dGF0b3IpCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>