<?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>109287</bug_id>
          
          <creation_ts>2013-02-08 05:07:28 -0800</creation_ts>
          <short_desc>[GTK] Crash in webkitURIResponseSetCertificateInfo()</short_desc>
          <delta_ts>2013-02-19 09:51:28 -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>WebKitGTK</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>http://renevier.net/misc/webkit_109225.php</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>109566</dependson>
    
    <dependson>110190</dependson>
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Claudio Saavedra">csaavedra</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>a.renevier</cc>
    
    <cc>buildbot</cc>
    
    <cc>cgarcia</cc>
    
    <cc>gustavo</cc>
    
    <cc>mrobinson</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>828456</commentid>
    <comment_count>0</comment_count>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2013-02-08 05:07:28 -0800</bug_when>
    <thetext>Stacktrace:

#0  0x00007ffff6313647 in webkitURIResponseSetCertificateInfo(_WebKitURIResponse*, WebKit::WebCertificateInfo*) ()
   from /home/claudio/git/gnome/WebKit/WebKitBuild/Release/.libs/libwebkit2gtk-3.0.so.0
#1  0x00007ffff6321dc1 in webkitWebViewLoadChanged(_WebKitWebView*, WebKitLoadEvent) ()
   from /home/claudio/git/gnome/WebKit/WebKitBuild/Release/.libs/libwebkit2gtk-3.0.so.0
#2  0x00007ffff63795e0 in WebKit::WebPageProxy:idCommitLoadForFrame(unsigned long, WTF:tring const&amp;, bool, unsigned int, WebKit:latformCertificateInfo const&amp;, CoreIPC::MessageDecoder&amp;) ()

Quick analysis:

WebKitWebView&apos;s setCertificateToMainResource() is calling webkitURIResponseSetCertificateInfo() and passing an unchecked call to webkit_web_resource_get_response() as the WebKitURIResponse parameter. The docs for webkit_web_resource_get_response() tell that this function can return NULL but webkitURIResponseSetCertificateInfo() doesn&apos;t check for this and dereferences directly.

The quick fix would be not to call to webkitURIResponseSetCertificateInfo() if the webresource doesn&apos;t have yet a response, but I am not sure whether this is the right thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>828458</commentid>
    <comment_count>1</comment_count>
      <attachid>187294</attachid>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2013-02-08 05:19:27 -0800</bug_when>
    <thetext>Created attachment 187294
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>828463</commentid>
    <comment_count>2</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2013-02-08 05:23:26 -0800</bug_when>
    <thetext>Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>828494</commentid>
    <comment_count>3</comment_count>
      <attachid>187294</attachid>
    <who name="Build Bot">buildbot</who>
    <bug_when>2013-02-08 06:00:46 -0800</bug_when>
    <thetext>Comment on attachment 187294
Patch

Attachment 187294 did not pass mac-wk2-ews (mac-wk2):
Output: http://queues.webkit.org/results/16427616

New failing tests:
http/tests/cache/cached-main-resource.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>828562</commentid>
    <comment_count>4</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2013-02-08 07:40:51 -0800</bug_when>
    <thetext>*** Bug 109225 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>828637</commentid>
    <comment_count>5</comment_count>
    <who name="arno.">a.renevier</who>
    <bug_when>2013-02-08 09:38:08 -0800</bug_when>
    <thetext>(In reply to comment #0)
&gt; 
&gt; The quick fix would be not to call to webkitURIResponseSetCertificateInfo() if the webresource doesn&apos;t have yet a response, but I am not sure whether this is the right thing.


Then, when response arrives later, it would not get a certificate info. What are the implications of that ?

Would that work better by always registering a notify::response callback on the main response, and calling setCertificateToMainResource from there ?


Also, even with that patch, there still is problem:
at *third* load of a page with 304 code, the page does not load (try to go to http://localhost/tmp/crash.php at 3rd load, network panel in error console show that the request has been aborted). That is because webkitWebViewDecidePolicy receives the 304 response with a null mimetype the second time (but not the first time). That is probably another bug though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>828997</commentid>
    <comment_count>6</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2013-02-09 03:21:12 -0800</bug_when>
    <thetext>(In reply to comment #0)
&gt; Stacktrace:
&gt; 
&gt; #0  0x00007ffff6313647 in webkitURIResponseSetCertificateInfo(_WebKitURIResponse*, WebKit::WebCertificateInfo*) ()
&gt;    from /home/claudio/git/gnome/WebKit/WebKitBuild/Release/.libs/libwebkit2gtk-3.0.so.0
&gt; #1  0x00007ffff6321dc1 in webkitWebViewLoadChanged(_WebKitWebView*, WebKitLoadEvent) ()
&gt;    from /home/claudio/git/gnome/WebKit/WebKitBuild/Release/.libs/libwebkit2gtk-3.0.so.0
&gt; #2  0x00007ffff63795e0 in WebKit::WebPageProxy:idCommitLoadForFrame(unsigned long, WTF:tring const&amp;, bool, unsigned int, WebKit:latformCertificateInfo const&amp;, CoreIPC::MessageDecoder&amp;) ()
&gt; 
&gt; Quick analysis:
&gt; 
&gt; WebKitWebView&apos;s setCertificateToMainResource() is calling webkitURIResponseSetCertificateInfo() and passing an unchecked call to webkit_web_resource_get_response() as the WebKitURIResponse parameter. The docs for webkit_web_resource_get_response() tell that this function can return NULL but webkitURIResponseSetCertificateInfo() doesn&apos;t check for this and dereferences directly.

webkit_we_resource_get_response can return NULL, but it should never happen when setCertificateToMainResource is called, how can I reproduce this crash?

&gt; The quick fix would be not to call to webkitURIResponseSetCertificateInfo() if the webresource doesn&apos;t have yet a response, but I am not sure whether this is the right thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>829056</commentid>
    <comment_count>7</comment_count>
    <who name="arno.">a.renevier</who>
    <bug_when>2013-02-09 10:09:52 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #0)
&gt; &gt; Stacktrace:
&gt; &gt; 
&gt; &gt; #0  0x00007ffff6313647 in webkitURIResponseSetCertificateInfo(_WebKitURIResponse*, WebKit::WebCertificateInfo*) ()
&gt; &gt;    from /home/claudio/git/gnome/WebKit/WebKitBuild/Release/.libs/libwebkit2gtk-3.0.so.0
&gt; &gt; #1  0x00007ffff6321dc1 in webkitWebViewLoadChanged(_WebKitWebView*, WebKitLoadEvent) ()
&gt; &gt;    from /home/claudio/git/gnome/WebKit/WebKitBuild/Release/.libs/libwebkit2gtk-3.0.so.0
&gt; &gt; #2  0x00007ffff63795e0 in WebKit::WebPageProxy:idCommitLoadForFrame(unsigned long, WTF:tring const&amp;, bool, unsigned int, WebKit:latformCertificateInfo const&amp;, CoreIPC::MessageDecoder&amp;) ()
&gt; &gt; 
&gt; &gt; Quick analysis:
&gt; &gt; 
&gt; &gt; WebKitWebView&apos;s setCertificateToMainResource() is calling webkitURIResponseSetCertificateInfo() and passing an unchecked call to webkit_web_resource_get_response() as the WebKitURIResponse parameter. The docs for webkit_web_resource_get_response() tell that this function can return NULL but webkitURIResponseSetCertificateInfo() doesn&apos;t check for this and dereferences directly.
&gt; 
&gt; webkit_we_resource_get_response can return NULL, but it should never happen when setCertificateToMainResource is called, how can I reproduce this crash?
&gt; 
&gt; &gt; The quick fix would be not to call to webkitURIResponseSetCertificateInfo() if the webresource doesn&apos;t have yet a response, but I am not sure whether this is the right thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>829057</commentid>
    <comment_count>8</comment_count>
    <who name="arno.">a.renevier</who>
    <bug_when>2013-02-09 10:11:30 -0800</bug_when>
    <thetext>(In reply to comment #7)

&gt; &gt; webkit_we_resource_get_response can return NULL, but it should never happen when setCertificateToMainResource is called, how can I reproduce this crash?

Oups, looks like I copy/pasted the wrong url.
the crash happens in case of a 304 http code.
If you load http://renevier.net/misc/webkit_109225.php in MiniBrowser and reload it, it should crash.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>829059</commentid>
    <comment_count>9</comment_count>
      <attachid>187436</attachid>
    <who name="arno.">a.renevier</who>
    <bug_when>2013-02-09 10:16:13 -0800</bug_when>
    <thetext>Created attachment 187436
test page source</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830787</commentid>
    <comment_count>10</comment_count>
      <attachid>187294</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2013-02-12 04:54:21 -0800</bug_when>
    <thetext>Comment on attachment 187294
Patch

This is not the right fix, as I said, that situation should never happen and it&apos;s actually a bug in WebCore, see bug https://bugs.webkit.org/show_bug.cgi?id=109566</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>836496</commentid>
    <comment_count>11</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2013-02-19 09:51:28 -0800</bug_when>
    <thetext>This is fixed now since webkitURIResponseSetCertificateInfo() doesn&apos;t exist anymore.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>187294</attachid>
            <date>2013-02-08 05:19:27 -0800</date>
            <delta_ts>2013-02-12 04:54:21 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-109287-20130208151600.patch</filename>
            <type>text/plain</type>
            <size>1835</size>
            <attacher name="Claudio Saavedra">csaavedra</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTQyMDk1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0Mi9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViS2l0Mi9DaGFuZ2VMb2cKaW5kZXggOTU5OGU1MDIyMzU3Y2E0
ZDk3MjhjYjdlMTU4ZmIwYmJiYmMxODY0Yy4uYWI0MmYzMjkyMDEzYWZmOWI5NDk1OWIzODE0ZWM3
MTkzYTFkNzI4MSAxMDA2NDQKLS0tIGEvU291cmNlL1dlYktpdDIvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJLaXQyL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE0IEBACisyMDEzLTAyLTA4ICBDbGF1
ZGlvIFNhYXZlZHJhICA8Y3NhYXZlZHJhQGlnYWxpYS5jb20+CisKKyAgICAgICAgW0dUS10gQ3Jh
c2ggaW4gd2Via2l0VVJJUmVzcG9uc2VTZXRDZXJ0aWZpY2F0ZUluZm8oKQorICAgICAgICBodHRw
czovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MTA5Mjg3CisKKyAgICAgICAgUmV2
aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgKiBVSVByb2Nlc3MvQVBJL2d0ay9X
ZWJLaXRXZWJWaWV3LmNwcDoKKyAgICAgICAgKHNldENlcnRpZmljYXRlVG9NYWluUmVzb3VyY2Up
OiBEbyBub3QgYXNzdW1lIHRoZSBtYWluIHJlc291cmNlCisgICAgICAgIGFscmVhZHkgaGFzIGEg
dXJpIHJlc3BvbnNlLgorCiAyMDEzLTAxLTMxICBDbGF1ZGlvIFNhYXZlZHJhICA8Y3NhYXZlZHJh
QGlnYWxpYS5jb20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z2V0KCkpLT5jZXJ0aWZpY2F0ZUluZm8oKSk7CisgICAgaWYgKFdlYktpdFVSSVJlc3BvbnNlKiBy
ZXNwb25zZSA9IHdlYmtpdF93ZWJfcmVzb3VyY2VfZ2V0X3Jlc3BvbnNlKHByaXYtPm1haW5SZXNv
dXJjZS5nZXQoKSkpCisgICAgICAgIHdlYmtpdFVSSVJlc3BvbnNlU2V0Q2VydGlmaWNhdGVJbmZv
KHJlc3BvbnNlLCB3ZWJraXRXZWJSZXNvdXJjZUdldEZyYW1lKHByaXYtPm1haW5SZXNvdXJjZS5n
ZXQoKSktPmNlcnRpZmljYXRlSW5mbygpKTsKIH0KIAogc3RhdGljIHZvaWQgd2Via2l0V2ViVmll
d0VtaXRMb2FkQ2hhbmdlZChXZWJLaXRXZWJWaWV3KiB3ZWJWaWV3LCBXZWJLaXRMb2FkRXZlbnQg
bG9hZEV2ZW50KQo=
</data>
<flag name="review"
          id="207062"
          type_id="1"
          status="-"
          setter="cgarcia"
    />
    <flag name="commit-queue"
          id="207063"
          type_id="3"
          status="-"
          setter="buildbot"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>187436</attachid>
            <date>2013-02-09 10:16:13 -0800</date>
            <delta_ts>2013-02-09 10:16:13 -0800</delta_ts>
            <desc>test page source</desc>
            <filename>webkit_109225.php</filename>
            <type>application/x-php</type>
            <size>245</size>
            <attacher name="arno.">a.renevier</attacher>
            
              <data encoding="base64">PD9waHAKJGNvbnRlbnQgPSAiPGh0bWw+aGVsbG8gd29ybGQ8L2h0bWw+IjsKJG1kNSA9IG1kNSgk
Y29udGVudCk7CmlmICgkX1NFUlZFUlsiSFRUUF9JRl9OT05FX01BVENIIl0gPT0gJG1kNSkgewog
ICAgaGVhZGVyKCRfU0VSVkVSWydTRVJWRVJfUFJPVE9DT0wnXS4nIDMwNCBOb3QgTW9kaWZpZWQn
LCB0cnVlLCAzMDQpOwp9IGVsc2UgewogICAgaGVhZGVyKCJFVGFnOiAkbWQ1Iik7CiAgICBwcmlu
dCAkY29udGVudDsKfQo/Pgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>