<?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>203620</bug_id>
          
          <creation_ts>2019-10-30 11:26:16 -0700</creation_ts>
          <short_desc>[SOUP] HSTS Support causes page loading to fail with &quot;Operation was cancelled&quot;</short_desc>
          <delta_ts>2020-01-07 01:58: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>WebKitGTK</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=204736</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Patrick Griffis">pgriffis</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>csaavedra</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1585438</commentid>
    <comment_count>0</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2019-10-30 11:26:16 -0700</bug_when>
    <thetext>Steps to reproduce:

Load HSTS using site like `http://google.com`, upon redirection it will often but not always fail.

It also hits the soupRequest assertion in `NetworkDataTaskSoup::sendRequestCallback()` in these cases.



Modifying libsoup to never return a policy made the issue go away.

This was originally reported against GLib: https://gitlab.gnome.org/GNOME/glib/issues/1891</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1585842</commentid>
    <comment_count>1</comment_count>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2019-10-31 03:42:33 -0700</bug_when>
    <thetext>I can hit this in ephy but not in minibrowser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1588623</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-11-08 06:55:35 -0800</bug_when>
    <thetext>Just hit this bug twice in a row when loading http://webkitgtk.org. On the third attempt, the load worked. I can no longer reproduce.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1589165</commentid>
    <comment_count>3</comment_count>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2019-11-11 04:53:01 -0800</bug_when>
    <thetext>MiniBrowser or Epiphany?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1589168</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-11-11 05:24:49 -0800</bug_when>
    <thetext>Epiphany</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1589171</commentid>
    <comment_count>5</comment_count>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2019-11-11 05:29:24 -0800</bug_when>
    <thetext>I&apos;m wondering if it&apos;s possible that the issue is in Epiphany.. because I couldn&apos;t reproduce this at all in MiniBrowser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1589179</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-11-11 06:31:14 -0800</bug_when>
    <thetext>(In reply to Patrick Griffis from comment #0)
&gt; Steps to reproduce:
&gt; 
&gt; Load HSTS using site like `http://google.com`, upon redirection it will
&gt; often but not always fail.
&gt; 
&gt; It also hits the soupRequest assertion in
&gt; `NetworkDataTaskSoup::sendRequestCallback()` in these cases.

Well you&apos;re hitting an assertion in WebKit network process. That&apos;s definitely not Epiphany&apos;s fault.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1589337</commentid>
    <comment_count>7</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2019-11-11 14:47:33 -0800</bug_when>
    <thetext>Also I used Cog+WPE for reproducing this, Epiphany isn&apos;t relevant.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1596923</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-12-09 12:47:42 -0800</bug_when>
    <thetext>Ping, this is important....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1598809</commentid>
    <comment_count>9</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2019-12-16 01:47:07 -0800</bug_when>
    <thetext>I&apos;ve never seen this error and I can&apos;t reproduce it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1598843</commentid>
    <comment_count>10</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-12-16 05:47:24 -0800</bug_when>
    <thetext>It has never been reproducible. But fortunately, Patrick has already debugged it fairly well:

(In reply to Patrick Griffis from comment #0)
&gt; It also hits the soupRequest assertion in
&gt; `NetworkDataTaskSoup::sendRequestCallback()` in these cases.
&gt; 
&gt; 
&gt; 
&gt; Modifying libsoup to never return a policy made the issue go away.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1599267</commentid>
    <comment_count>11</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2019-12-16 19:53:44 -0800</bug_when>
    <thetext>With wpewebkit-2.27.1 I can reproduce extremely consistently.

Changing no deps but running against r253428 (git ac429352178b2ff4460e775cfd4b1fb79621d4ad) I cannot reproduce at all.

So I&apos;m inclined to believe it was resolved unless Michael can reproduce it against trunk.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1599422</commentid>
    <comment_count>12</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-12-17 08:07:41 -0800</bug_when>
    <thetext>I&apos;ve never been able to reproduce it consistently. So if you&apos;re confident it&apos;s solved, then that&apos;s great. It&apos;s very weird an issue like this would just resolve itself, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1599423</commentid>
    <comment_count>13</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-12-17 08:11:10 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #12)
&gt; I&apos;ve never been able to reproduce it consistently.

I went back and built WebKitGTK 2.27.1, deleted my HSTS database, and loaded http://google.com. I was successfully redirected to https. Then I closed Epiphany, deleted my HSTS database again, and repeated the process several times. I was never able to reproduce. So we&apos;ll need to rely on your observations here.

Of course, I&apos;ll reopen if I see it again.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1602415</commentid>
    <comment_count>14</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2020-01-03 07:14:32 -0800</bug_when>
    <thetext>I can reproduce this now with WPE MiniBrowser and cog. The problem is that we are assuming that request cancellation happens synchronously, but it can happen that the async ready callback for the previous request is called after the new one has started.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1602416</commentid>
    <comment_count>15</comment_count>
      <attachid>386681</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2020-01-03 07:16:52 -0800</bug_when>
    <thetext>Created attachment 386681
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1602453</commentid>
    <comment_count>16</comment_count>
      <attachid>386681</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2020-01-03 09:00:26 -0800</bug_when>
    <thetext>Comment on attachment 386681
Patch

Aha, nice find!

One problem though: the user data parameter NetworkDataTaskSoup* task is passed to this callback using leakRef(), but now you&apos;ve added this new early return before the ref is adopted, causing the task to leak. So this needs to go down below that at least. How about like this:

RefPtr&lt;NetworkDataTaskSoup&gt; protectedThis = adoptRef(task);
if (soupRequest != task-&gt;m_soupRequest.get()) {
    // ...
}
if (task-&gt;state() == State::Canceling || task-&gt;state() == State::Completed || !task-&gt;m_client) {
    // ...
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1602456</commentid>
    <comment_count>17</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2020-01-03 09:02:28 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #16)
&gt; RefPtr&lt;NetworkDataTaskSoup&gt; protectedThis = adoptRef(task);

Well, also protectedThis is the wrong name because it&apos;s not a protector, it&apos;s just required to adopt the ref.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1602728</commentid>
    <comment_count>18</comment_count>
      <attachid>386681</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2020-01-03 20:49:02 -0800</bug_when>
    <thetext>Comment on attachment 386681
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=386681&amp;action=review

&gt; Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:310
&gt;      RefPtr&lt;NetworkDataTaskSoup&gt; protectedThis = adoptRef(task);

Maybe we should do a global search to see if we have more places where the words &quot;protected&quot; or &quot;protector&quot; and &quot;adopt&quot; appear on the same line. Seems that will almost always indicate either a misnamed variable or, potentially, a bug. If it really *was* a protector (no adopt), then your change would have been fine as-is. I think you got tricked by the incorrect name.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1602840</commentid>
    <comment_count>19</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2020-01-05 05:20:17 -0800</bug_when>
    <thetext>You are right, and it was indeed the name protectedThis what confused me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1603495</commentid>
    <comment_count>20</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2020-01-07 01:58:08 -0800</bug_when>
    <thetext>Committed r254119: &lt;https://trac.webkit.org/changeset/254119&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>386681</attachid>
            <date>2020-01-03 07:16:52 -0800</date>
            <delta_ts>2020-01-03 09:00:26 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>wk2-hsts-cancelled.diff</filename>
            <type>text/plain</type>
            <size>2424</size>
            <attacher name="Carlos Garcia Campos">cgarcia</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nIGIvU291cmNlL1dlYktpdC9DaGFu
Z2VMb2cKaW5kZXggMTg5YTRjOTRjNTkuLjRhZDNmNmE5YWU0IDEwMDY0NAotLS0gYS9Tb3VyY2Uv
V2ViS2l0L0NoYW5nZUxvZworKysgYi9Tb3VyY2UvV2ViS2l0L0NoYW5nZUxvZwpAQCAtMSwzICsx
LDE2IEBACisyMDIwLTAxLTAzICBDYXJsb3MgR2FyY2lhIENhbXBvcyAgPGNnYXJjaWFAaWdhbGlh
LmNvbT4KKworICAgICAgICBbU09VUF0gSFNUUyBTdXBwb3J0IGNhdXNlcyBwYWdlIGxvYWRpbmcg
dG8gZmFpbCB3aXRoICJPcGVyYXRpb24gd2FzIGNhbmNlbGxlZCIKKyAgICAgICAgaHR0cHM6Ly9i
dWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTIwMzYyMAorCisgICAgICAgIFJldmlld2Vk
IGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIFRoZSBwcm9ibGVtIGlzIHRoYXQgd2UgYXJl
IGFzc3VtaW5nIHRoYXQgcmVxdWVzdCBjYW5jZWxsYXRpb24gaGFwcGVucyBzeW5jaHJvbm91c2x5
LCBidXQgaXQgY2FuIGhhcHBlbiB0aGF0IHRoZQorICAgICAgICBhc3luYyByZWFkeSBjYWxsYmFj
ayBmb3IgdGhlIHByZXZpb3VzIHJlcXVlc3QgaXMgY2FsbGVkIGFmdGVyIHRoZSBuZXcgb25lIGhh
cyBzdGFydGVkLgorCisg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AgICB0YXNrLT5jbGVhclJlcXVlc3QoKTsKICAgICAgICAgcmV0dXJuOwogICAgIH0K
LSAgICBBU1NFUlQoc291cFJlcXVlc3QgPT0gdGFzay0+bV9zb3VwUmVxdWVzdC5nZXQoKSk7CiAK
ICAgICBpZiAodGFzay0+c3RhdGUoKSA9PSBTdGF0ZTo6U3VzcGVuZGVkKSB7CiAgICAgICAgIEFT
U0VSVCghdGFzay0+bV9wZW5kaW5nUmVzdWx0KTsK
</data>
<flag name="review"
          id="402456"
          type_id="1"
          status="+"
          setter="mcatanzaro"
    />
          </attachment>
      

    </bug>

</bugzilla>