<?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>181771</bug_id>
          
          <creation_ts>2018-01-17 16:36:49 -0800</creation_ts>
          <short_desc>REGRESSION (r223149): WebProcessProxy::didClose() no longer refs WebPageProxy objects</short_desc>
          <delta_ts>2018-01-22 12:20:08 -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>WebKit2</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=181863</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar, Regression</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>178102</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>beidson</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>dbates</cc>
    
    <cc>ggaren</cc>
    
    <cc>sam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1390285</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-17 16:36:49 -0800</bug_when>
    <thetext>WebProcessProxy::didClose() no longer refs WebPageProxy objects, leading to crashes:
Thread[0] EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000200000353)
[  0] 0x00000001945ccf58 WebKit`WebKit::WebPageProxy::processDidTerminate(WebKit::ProcessTerminationReason) [inlined] WebKit::WebProcessProxy::isUnderMemoryPressure() const at WebProcessProxy.h:184:49

     0x00000001945ccf48:      add x29, sp, #0x60       ; =0x60 
     0x00000001945ccf4c:      mov x20, x1
     0x00000001945ccf50:      mov x19, x0
     0x00000001945ccf54:      ldr x8, [x19, #0xc0]
 -&gt;  0x00000001945ccf58:     ldrb w8, [x8, #0x2d0]
     0x00000001945ccf5c:      cbz w8, 0x23d0a0         ; &lt;+356&gt; at WebPageProxy.cpp:5523
     0x00000001945ccf60:      add x8, sp, #0x8         ; =0x8 
     0x00000001945ccf64:      mov x0, x19
     0x00000001945ccf68:       bl 0x22e304             ; WebKit::WebPageProxy::currentURL at WebPageProxy.cpp:5503

[  0] 0x00000001945ccf58 WebKit`WebKit::WebPageProxy::processDidTerminate(WebKit::ProcessTerminationReason) + 28 at WebPageProxy.cpp:5515
[  1] 0x000000019464062b WebKit`WebKit::WebProcessProxy::didClose(IPC::Connection&amp;) + 523 at WebProcessProxy.cpp:643:15
[  2] 0x000000019464062b WebKit`WebKit::WebProcessProxy::didClose(IPC::Connection&amp;) + 523 at WebProcessProxy.cpp:643:15
[  3] 0x000000018c179dc7 JavaScriptCore`WTF::RunLoop::performWork() [inlined] WTF::Function&lt;void ()&gt;::operator()() const + 15 at Function.h:56:35
[  3] 0x000000018c179db8 JavaScriptCore`WTF::RunLoop::performWork() + 252 at RunLoop.cpp:106
[  4] 0x000000018c17a087 JavaScriptCore`WTF::RunLoop::performWork(void*) + 35 at RunLoopCF.cpp:38:37
[  5] 0x000000018435ca23 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 23 at CFRunLoop.c:1982:9
[  6] 0x000000018435c24b CoreFoundation`__CFRunLoopDoSources0 [inlined] __CFRunLoopDoSource0 + 67 at CFRunLoop.c:2017:13
[  6] 0x000000018435c208 CoreFoundation`__CFRunLoopDoSources0 + 208 at CFRunLoop.c:2053
[  7] 0x0000000184359dbb CoreFoundation`__CFRunLoopRun + 1203 at CFRunLoop.c:2920:41
[  8] 0x000000018427a5d7 CoreFoundation`CFRunLoopRunSpecific + 551 at CFRunLoop.c:3245:18
[  9] 0x000000018623b023 GraphicsServices`GSEventRunModal + 99 at GSEvent.c:2245:9
[ 10] 0x000000018e705a63 UIKit`UIApplicationMain + 235 at UIApplication.m:3956:5
[ 11] 0x000000010086e90b MobileSafari`main + 1927
[ 12] 0x0000000183d19faf libdyld.dylib`start + 3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1390286</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-17 16:37:02 -0800</bug_when>
    <thetext>&lt;rdar://problem/36566237&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1390288</commentid>
    <comment_count>2</comment_count>
      <attachid>331559</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-17 16:41:15 -0800</bug_when>
    <thetext>Created attachment 331559
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1390334</commentid>
    <comment_count>3</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2018-01-17 18:41:39 -0800</bug_when>
    <thetext>&quot;...no longer refs WebPageProxy objects...&quot;

This means it used to.

Why did it stop doing so?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1390347</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-17 19:01:43 -0800</bug_when>
    <thetext>(In reply to Brady Eidson from comment #3)
&gt; &quot;...no longer refs WebPageProxy objects...&quot;
&gt; 
&gt; This means it used to.
&gt; 
&gt; Why did it stop doing so?

Sorry, the explanation was only in the radar.

In WebProcessProxy::didClose():
Vector&lt;RefPtr&lt;WebPageProxy&gt;&gt; pages;
copyValuesToVector(m_pageMap, pages);

became (in r223149)
auto pages = copyToVector(m_pageMap.values());

“auto” here resolves to Vector&lt;WebPageProxy*&gt; so we no longer ref the pages. This is because m_pages is of type HashMap&lt;uint64_t, WebPageProxy*&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1390558</commentid>
    <comment_count>5</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-18 10:19:28 -0800</bug_when>
    <thetext>For the record, I tried writing an API test. The issue is that I cannot get the view to get destroyed in the processDidTerminate delegates. This is because all API tests run in an autorelease pool. Even though I release the webviews in the delegate, they only get deallocated later, at the end of the test, when the pool is drained.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1390622</commentid>
    <comment_count>6</comment_count>
      <attachid>331559</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-18 12:11:03 -0800</bug_when>
    <thetext>Comment on attachment 331559
Patch

Clearing flags on attachment: 331559

Committed r227157: &lt;https://trac.webkit.org/changeset/227157&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1390623</commentid>
    <comment_count>7</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-18 12:11:05 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1391559</commentid>
    <comment_count>8</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2018-01-21 23:40:32 -0800</bug_when>
    <thetext>Did we audit all the other loops we changed to see if any others need this sort of fix to restore the old behavior?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1391671</commentid>
    <comment_count>9</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-22 09:30:38 -0800</bug_when>
    <thetext>(In reply to Darin Adler from comment #8)
&gt; Did we audit all the other loops we changed to see if any others need this
&gt; sort of fix to restore the old behavior?

Daniel Bates landed a follow-up patch in https://bugs.webkit.org/show_bug.cgi?id=178102.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1391727</commentid>
    <comment_count>10</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-01-22 11:24:16 -0800</bug_when>
    <thetext>(In reply to Chris Dumez from comment #9)
&gt; (In reply to Darin Adler from comment #8)
&gt; &gt; Did we audit all the other loops we changed to see if any others need this
&gt; &gt; sort of fix to restore the old behavior?
&gt; 
&gt; Daniel Bates landed a follow-up patch in
&gt; https://bugs.webkit.org/show_bug.cgi?id=178102.

I take it you meant to write that the follow up patch is on bug #181863.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1391738</commentid>
    <comment_count>11</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-01-22 12:20:08 -0800</bug_when>
    <thetext>(In reply to Daniel Bates from comment #10)
&gt; (In reply to Chris Dumez from comment #9)
&gt; &gt; (In reply to Darin Adler from comment #8)
&gt; &gt; &gt; Did we audit all the other loops we changed to see if any others need this
&gt; &gt; &gt; sort of fix to restore the old behavior?
&gt; &gt; 
&gt; &gt; Daniel Bates landed a follow-up patch in
&gt; &gt; https://bugs.webkit.org/show_bug.cgi?id=178102.
&gt; 
&gt; I take it you meant to write that the follow up patch is on bug #181863.

Yes indeed.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>331559</attachid>
            <date>2018-01-17 16:41:15 -0800</date>
            <delta_ts>2018-01-18 12:11:03 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-181771-20180117164115.patch</filename>
            <type>text/plain</type>
            <size>1420</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjI3MDg3CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IGE2NTAxYWJmNTNlYTM3MTlm
ODcxZDgyOTg3YzdjYzc1NTI0YWE1ZjIuLm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