<?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>206057</bug_id>
          
          <creation_ts>2020-01-10 03:23:48 -0800</creation_ts>
          <short_desc>CacheStorage::Engine::clearCachesForOriginFromDisk ASSERT is buggy</short_desc>
          <delta_ts>2020-01-14 01:17:52 -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>Service Workers</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="youenn fablet">youennf</reporter>
          <assigned_to name="youenn fablet">youennf</assigned_to>
          <cc>cdumez</cc>
    
    <cc>cgarcia</cc>
    
    <cc>commit-queue</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wilander</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1605049</commentid>
    <comment_count>0</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-01-10 03:23:48 -0800</bug_when>
    <thetext>CacheStorage::Engine::clearCachesForOriginFromDisk ASSERT is buggy</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1605050</commentid>
    <comment_count>1</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-01-10 03:24:05 -0800</bug_when>
    <thetext>&lt;rdar://problem/57762994&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1605051</commentid>
    <comment_count>2</comment_count>
      <attachid>387324</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-01-10 03:30:29 -0800</bug_when>
    <thetext>Created attachment 387324
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1605123</commentid>
    <comment_count>3</comment_count>
    <who name="John Wilander">wilander</who>
    <bug_when>2020-01-10 08:52:38 -0800</bug_when>
    <thetext>Since I was able to reproduce this issue, could a test be created?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1605127</commentid>
    <comment_count>4</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-01-10 08:57:13 -0800</bug_when>
    <thetext>(In reply to John Wilander from comment #3)
&gt; Since I was able to reproduce this issue, could a test be created?

I guess we could write an API test that would:
- Trigger some persistent cache storage.
- Tear down the network process
- Create a new network process and clear the cache storage.

I am not sure this is worth it though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1605959</commentid>
    <comment_count>5</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-01-13 11:14:03 -0800</bug_when>
    <thetext>Ping review.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1605963</commentid>
    <comment_count>6</comment_count>
      <attachid>387324</attachid>
    <who name="John Wilander">wilander</who>
    <bug_when>2020-01-13 11:23:49 -0800</bug_when>
    <thetext>Comment on attachment 387324
Patch

cachesRootPath() returns the empty string if the salt is not set, like so:

String Engine::cachesRootPath(const WebCore::ClientOrigin&amp; origin)
{
    if (!shouldPersist() || !m_salt)
        return { };
  …
}

With your change, we&apos;re saying folderPath does not have to be equal to the return value of cachesRootPath() if we don&apos;t have a salt. Then we go ahead and call deleteDirectoryRecursivelyOnBackgroundThread() with the folderPath that does not match the return value of cachesRootPath(). Is that correct?

My assumption would be to return early if the path is empty.

We need a comment to explain this logic in my opinion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1605975</commentid>
    <comment_count>7</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-01-13 11:58:16 -0800</bug_when>
    <thetext>(In reply to John Wilander from comment #6)
&gt; Comment on attachment 387324 [details]
&gt; Patch
&gt; 
&gt; cachesRootPath() returns the empty string if the salt is not set, like so:
&gt; 
&gt; String Engine::cachesRootPath(const WebCore::ClientOrigin&amp; origin)
&gt; {
&gt;     if (!shouldPersist() || !m_salt)
&gt;         return { };
&gt;   …
&gt; }
&gt; 
&gt; With your change, we&apos;re saying folderPath does not have to be equal to the
&gt; return value of cachesRootPath() if we don&apos;t have a salt. Then we go ahead
&gt; and call deleteDirectoryRecursivelyOnBackgroundThread() with the folderPath
&gt; that does not match the return value of cachesRootPath(). Is that correct?
&gt; 
&gt; My assumption would be to return early if the path is empty.

If the path is empty, cache salt has not be read/was not readable.

We are always deleting data from the origin given to the method.
The reason is that we read the folder origin directly from the &quot;origin&quot; file inside that folder.
I guess we could add a comment for that.

&gt; We need a comment to explain this logic in my opinion.

It seems the issue you have is with the purpose of the ASSERT, right?
I can add something like: // If cache salt is initialised and the paths do not match, some cache files are probably partially corrupted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1605981</commentid>
    <comment_count>8</comment_count>
    <who name="John Wilander">wilander</who>
    <bug_when>2020-01-13 12:12:57 -0800</bug_when>
    <thetext>(In reply to youenn fablet from comment #7)
&gt; (In reply to John Wilander from comment #6)
&gt; &gt; Comment on attachment 387324 [details]
&gt; &gt; Patch
&gt; &gt; 
&gt; &gt; cachesRootPath() returns the empty string if the salt is not set, like so:
&gt; &gt; 
&gt; &gt; String Engine::cachesRootPath(const WebCore::ClientOrigin&amp; origin)
&gt; &gt; {
&gt; &gt;     if (!shouldPersist() || !m_salt)
&gt; &gt;         return { };
&gt; &gt;   …
&gt; &gt; }
&gt; &gt; 
&gt; &gt; With your change, we&apos;re saying folderPath does not have to be equal to the
&gt; &gt; return value of cachesRootPath() if we don&apos;t have a salt. Then we go ahead
&gt; &gt; and call deleteDirectoryRecursivelyOnBackgroundThread() with the folderPath
&gt; &gt; that does not match the return value of cachesRootPath(). Is that correct?
&gt; &gt; 
&gt; &gt; My assumption would be to return early if the path is empty.
&gt; 
&gt; If the path is empty, cache salt has not be read/was not readable.
&gt; 
&gt; We are always deleting data from the origin given to the method.
&gt; The reason is that we read the folder origin directly from the &quot;origin&quot; file
&gt; inside that folder.
&gt; I guess we could add a comment for that.
&gt; 
&gt; &gt; We need a comment to explain this logic in my opinion.
&gt; 
&gt; It seems the issue you have is with the purpose of the ASSERT, right?
&gt; I can add something like: // If cache salt is initialised and the paths do
&gt; not match, some cache files are probably partially corrupted.

r+ with the comment and US English spelling &quot;initialised&quot; –&gt; &quot;initialized&quot; :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606264</commentid>
    <comment_count>9</comment_count>
      <attachid>387622</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-01-13 23:07:13 -0800</bug_when>
    <thetext>Created attachment 387622
Patch for landing</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606301</commentid>
    <comment_count>10</comment_count>
      <attachid>387622</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2020-01-14 01:17:50 -0800</bug_when>
    <thetext>Comment on attachment 387622
Patch for landing

Clearing flags on attachment: 387622

Committed r254501: &lt;https://trac.webkit.org/changeset/254501&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606302</commentid>
    <comment_count>11</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2020-01-14 01:17:52 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>387324</attachid>
            <date>2020-01-10 03:30:29 -0800</date>
            <delta_ts>2020-01-13 23:07:09 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-206057-20200110123027.patch</filename>
            <type>text/plain</type>
            <size>1957</size>
            <attacher name="youenn fablet">youennf</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjU0MzMwCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IDk5OWNlMjk4YWFlNDhlZTUw
ZDE0ZTA3YjMxN2VmY2Y1M2QxN2YzNDUuLjkxNGVkNDVkOTg5ZmM0MzE0ZWFjYjRhYTZkYjFiNjUy
ZTkyYTJjODggMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCisrKyBiL1NvdXJj
ZS9XZWJLaXQvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTggQEAKKzIwMjAtMDEtMTAgIHlvdWVubiBm
YWJsZXQgIDx5b3Vlbm5AYXBwbGUuY29tPgorCisgICAgICAgIENhY2hlU3RvcmFnZTo6RW5naW5l
OjpjbGVhckNhY2hlc0Zvck9yaWdpbkZyb21EaXNrIEFTU0VSVCBpcyBidWdneQorICAgICAgICBo
dHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MjA2MDU3CisgICAgICAgIDxy
ZGFyOi8vcHJvYmxlbS81Nzc2Mjk5ND4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9P
UFMhKS4KKworICAgICAgICBUaGUgQVNTRVJUIGlzIG9ubHkgdmFsaWQgaWYgdGhlIGVuZ2luZSBp
cyBpbml0aWFsaXplZC4KKyAgICAgICAgSXQgaXMgbm90IG5lZWRlZCB0byBpbml0aWFsaXplIGl0
IGlmIHRoZSBwbGFuIGlzIHRvIHJlbW92ZSBhbGwgZGlzayBmaWxlcy4KKyAgICAgICAgSW5zdGVh
ZCwgdXBkYXRlIEFTU0VSVCB0byBjaGVjayB0aGF0IGVpdGhlciBtX3NhbHQgaXMgbm90IHRoZXJl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dG9yaWVzKGNvbnN0IFZlY3RvcjxTdHJpbmc+JiBm
b2xkZXJQYXQKICAgICAgICAgICAgIGlmIChmb2xkZXJPcmlnaW4tPnRvcE9yaWdpbiAhPSBvcmln
aW4gJiYgZm9sZGVyT3JpZ2luLT5jbGllbnRPcmlnaW4gIT0gb3JpZ2luKQogICAgICAgICAgICAg
ICAgIHJldHVybjsKIAotICAgICAgICAgICAgQVNTRVJUKGZvbGRlclBhdGggPT0gY2FjaGVzUm9v
dFBhdGgoKmZvbGRlck9yaWdpbikpOworICAgICAgICAgICAgQVNTRVJUKCFtX3NhbHQgfHwgZm9s
ZGVyUGF0aCA9PSBjYWNoZXNSb290UGF0aCgqZm9sZGVyT3JpZ2luKSk7CiAgICAgICAgICAgICBk
ZWxldGVEaXJlY3RvcnlSZWN1cnNpdmVseU9uQmFja2dyb3VuZFRocmVhZChmb2xkZXJQYXRoLCBb
Y2FsbGJhY2tBZ2dyZWdhdG9yID0gV1RGTW92ZShjYWxsYmFja0FnZ3JlZ2F0b3IpXSB7IH0pOwog
ICAgICAgICB9KTsKICAgICB9Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>387622</attachid>
            <date>2020-01-13 23:07:13 -0800</date>
            <delta_ts>2020-01-14 01:17:50 -0800</delta_ts>
            <desc>Patch for landing</desc>
            <filename>bug-206057-20200114080712.patch</filename>
            <type>text/plain</type>
            <size>2030</size>
            <attacher name="youenn fablet">youennf</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjU0NDk2CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IDJjZGRhZDg1NTliMDUxOGYx
NmRhM2JiMWZlNGY5ZjhiNDQ4NGU4MTMuLjY5NzRhY2ZjZGUyNTA4YTc3NmM3MzhiZDZlYjE4MzRi
OTM4MzU2YjEg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