<?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>186827</bug_id>
          
          <creation_ts>2018-06-19 16:52:35 -0700</creation_ts>
          <short_desc>Crash in sanitizeStackForVMImpl sometimes when switching threads with same VM</short_desc>
          <delta_ts>2018-06-19 17:45:15 -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="Michael Saboff">msaboff</reporter>
          <assigned_to name="Michael Saboff">msaboff</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>saam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1434636</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2018-06-19 16:52:35 -0700</bug_when>
    <thetext>Crash something like:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.JavaScriptCore      	0x0000000116f5af53 sanitizeStackForVMImpl + 15
1   com.apple.JavaScriptCore      	0x000000011754889c JSC::Heap::collectInMutatorThread() + 44
2   com.apple.JavaScriptCore      	0x0000000117548794 JSC::Heap::stopIfNecessarySlow() + 68
3   com.apple.JavaScriptCore      	0x0000000117548a0f JSC::Heap::acquireAccessSlow() + 303
4   com.apple.JavaScriptCore      	0x000000011784ae6f JSC::JSLock::didAcquireLock() + 111
5   com.apple.JavaScriptCore      	0x0000000117868f9e JSC::JSRunLoopTimer::timerDidFireCallback(__CFRunLoopTimer*, void*) + 30
6   com.apple.CoreFoundation      	0x000000010e782124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
7   com.apple.CoreFoundation      	0x000000010e781cc9 __CFRunLoopDoTimer + 877
8   com.apple.CoreFoundation      	0x000000010e78189e __CFRunLoopDoTimers + 333
9   com.apple.CoreFoundation      	0x000000010e77a023 __CFRunLoopRun + 2193
...

This can occur if the VM was used on another thread and we need to take the Heap::acquireAccessSlow() path.  This happens because we switch VM::lastStackTop after calling Heap::acquireAccess().  The slow path of acquireAccess() ends up calling Heap::collectInMutatorThread() which sanitizes the stack, and if we haven&apos;t switched lastStackTop, we&apos;ll sanitize the current stack using the prior limits of another stack.  Then we&apos;ll walk all over memory and/or crash on an unmapped page.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1434637</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2018-06-19 16:52:46 -0700</bug_when>
    <thetext>&lt;rdar://problem/40624786&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1434638</commentid>
    <comment_count>2</comment_count>
      <attachid>343121</attachid>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2018-06-19 16:57:24 -0700</bug_when>
    <thetext>Created attachment 343121
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1434639</commentid>
    <comment_count>3</comment_count>
      <attachid>343121</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2018-06-19 16:58:27 -0700</bug_when>
    <thetext>Comment on attachment 343121
Patch

Can we add a test for this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1434645</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2018-06-19 17:06:47 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #3)
&gt; Comment on attachment 343121 [details]
&gt; Patch
&gt; 
&gt; Can we add a test for this?

I tried pretty hard in testapi.  The problem is how do you force Heap::acquireAccess() to take the slow path.  As a consolation, I did move the ASSERT() as well as the setting.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1434661</commentid>
    <comment_count>5</comment_count>
      <attachid>343121</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-06-19 17:45:14 -0700</bug_when>
    <thetext>Comment on attachment 343121
Patch

Clearing flags on attachment: 343121

Committed r232998: &lt;https://trac.webkit.org/changeset/232998&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1434662</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-06-19 17:45:15 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>343121</attachid>
            <date>2018-06-19 16:57:24 -0700</date>
            <delta_ts>2018-06-19 17:45:14 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>186827.patch</filename>
            <type>text/plain</type>
            <size>1764</size>
            <attacher name="Michael Saboff">msaboff</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291
cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkocmV2aXNpb24gMjMyOTkzKQorKysgU291cmNl
L0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkod29ya2luZyBjb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