<?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>135569</bug_id>
          
          <creation_ts>2014-08-04 12:16:32 -0700</creation_ts>
          <short_desc>Always clear ConsoleClient when Page/WindowShell is destroyed</short_desc>
          <delta_ts>2014-08-04 14:57:53 -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>WebCore Misc.</component>
          <version>528+ (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="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>ggaren</cc>
    
    <cc>joepeck</cc>
    
    <cc>mark.lam</cc>
    
    <cc>timothy</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1026662</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2014-08-04 12:16:32 -0700</bug_when>
    <thetext>* SUMMARY
WebCore::Page&apos;s set the ConsoleClient to their PageConsole object. It should always clear this pointer whenever the PageConsole is going away. Otherwise we could crash trying to use it.

Thread 0 Crashed:: main  Dispatch queue: com.apple.main-thread
0   ???                           	000000000000000000 0 + 0
1   com.apple.JavaScriptCore      	0x7fff973a9ca2 JSC::ConsoleClient::logWithLevel
2   com.apple.JavaScriptCore      	0x7fff973a8f3e JSC::consoleLogWithLevel
3   ???                           	0x000042ce8dc01114 0 + 73454908870932
4   com.apple.JavaScriptCore      	0x7fff973a5fbe llint_entry
5   com.apple.JavaScriptCore      	0x7fff973a04c1 callToJavaScript

&lt;rdar://problem/17856494&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1026663</commentid>
    <comment_count>1</comment_count>
      <attachid>235979</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2014-08-04 12:24:45 -0700</bug_when>
    <thetext>Created attachment 235979
[PATCH] Proposed Fix

I spent a bit of time trying to create a test for this. I have a manual test case, but it has two setTimeouts of 100ms, which I can&apos;t seem to reduce by much. Is that worth adding?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1026680</commentid>
    <comment_count>2</comment_count>
      <attachid>235979</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2014-08-04 13:47:01 -0700</bug_when>
    <thetext>Comment on attachment 235979
[PATCH] Proposed Fix

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1026686</commentid>
    <comment_count>3</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2014-08-04 14:01:48 -0700</bug_when>
    <thetext>Usually, it is the client&apos;s responsibility to clear this pointer, usually in the client object&apos;s destructor. Would that approach work here?

(I think this patch is fine too, but it would be a bit cleaner for the client to clear its own pointer.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1026687</commentid>
    <comment_count>4</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2014-08-04 14:23:12 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; Usually, it is the client&apos;s responsibility to clear this pointer, usually in the client object&apos;s destructor. Would that approach work here?
&gt; 
&gt; (I think this patch is fine too, but it would be a bit cleaner for the client to clear its own pointer.)

This is a little more complicated than that. During the lifetime of a page, it seems there may be the potential for multiple DOMWindow objects / JSGlobalObjects. As these come and go (page navigation) we want to make sure we configure the ConsoleClient in each of these to be the PageConsole.

Currently this happens in WindowShell initialization and clearing in ScriptController. With one other place in ScriptCachedFrameData::restore when a page is created from the page cache. Here we are fixing an overlooked case in destruction (which doesn&apos;t go through the normal clearing path).

I agree, this is messy and should be made clearer somehow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1026694</commentid>
    <comment_count>5</comment_count>
      <attachid>235979</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2014-08-04 14:57:50 -0700</bug_when>
    <thetext>Comment on attachment 235979
[PATCH] Proposed Fix

Clearing flags on attachment: 235979

Committed r172006: &lt;http://trac.webkit.org/changeset/172006&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1026695</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2014-08-04 14:57:53 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>235979</attachid>
            <date>2014-08-04 12:24:45 -0700</date>
            <delta_ts>2014-08-04 14:57:50 -0700</delta_ts>
            <desc>[PATCH] Proposed Fix</desc>
            <filename>console-client.patch</filename>
            <type>text/plain</type>
            <size>1626</size>
            <attacher name="Joseph Pecoraro">joepeck</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppbmRleCBjZWNiMmJkLi4xYWE5NGU0IDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29y
ZS9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTUg
QEAKKzIwMTQtMDgtMDQgIEpvc2VwaCBQZWNvcmFybyAgPHBlY29yYXJvQGFwcGxlLmNvbT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luZ3MvanMvU2NyaXB0Q29udHJvbGxlci5jcHAKQEAgLTk0LDggKzk0LDExIEBAIFNjcmlw
dENvbnRyb2xsZXI6On5TY3JpcHRDb250cm9sbGVyKCkKIAogICAgIC8vIEl0J3MgbGlrZWx5IHRo
YXQgZGVzdHJveWluZyBtX3dpbmRvd1NoZWxscyB3aWxsIGNyZWF0ZSBhIGxvdCBvZiBnYXJiYWdl
LgogICAgIGlmICghbV93aW5kb3dTaGVsbHMuaXNFbXB0eSgpKSB7Ci0gICAgICAgIHdoaWxlICgh
bV93aW5kb3dTaGVsbHMuaXNFbXB0eSgpKQotICAgICAgICAgICAgZGVzdHJveVdpbmRvd1NoZWxs
KCptX3dpbmRvd1NoZWxscy5iZWdpbigpLT5rZXkpOworICAgICAgICB3aGlsZSAoIW1fd2luZG93
U2hlbGxzLmlzRW1wdHkoKSkgeworICAgICAgICAgICAgU2hlbGxNYXA6Oml0ZXJhdG9yIGl0ZXIg
PSBtX3dpbmRvd1NoZWxscy5iZWdpbigpOworICAgICAgICAgICAgaXRlci0+dmFsdWUtPndpbmRv
dygpLT5zZXRDb25zb2xlQ2xpZW50KG51bGxwdHIpOworICAgICAgICAgICAgZGVzdHJveVdpbmRv
d1NoZWxsKCppdGVyLT5rZXkpOworICAgICAgICB9CiAgICAgICAgIGdjQ29udHJvbGxlcigpLmdh
cmJhZ2VDb2xsZWN0U29vbigpOwogICAgIH0KIH0K
</data>

          </attachment>
      

    </bug>

</bugzilla>