Bug 159834 - Use SecurityOriginData as keys in StorageManager
Summary: Use SecurityOriginData as keys in StorageManager
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-15 14:16 PDT by Alex Christensen
Modified: 2016-11-11 17:21 PST (History)
4 users (show)

See Also:


Attachments
Patch (40.13 KB, patch)
2016-07-15 14:34 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (40.13 KB, patch)
2016-07-15 14:50 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (40.00 KB, patch)
2016-07-15 15:01 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (40.01 KB, patch)
2016-07-15 15:38 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (40.03 KB, patch)
2016-07-15 16:38 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (40.04 KB, patch)
2016-07-15 16:56 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews115 for mac-yosemite (1.74 MB, application/zip)
2016-07-15 17:39 PDT, Build Bot
no flags Details
Patch (40.07 KB, patch)
2016-07-15 17:49 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (82.83 KB, patch)
2016-11-10 16:01 PST, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (81.37 KB, patch)
2016-11-10 16:42 PST, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (83.75 KB, patch)
2016-11-10 16:51 PST, Alex Christensen
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews105 for mac-yosemite-wk2 (2.02 MB, application/zip)
2016-11-10 17:48 PST, Build Bot
no flags Details
Archive of layout-test-results from ews124 for ios-simulator-wk2 (3.59 MB, application/zip)
2016-11-10 17:59 PST, Build Bot
no flags Details
Patch (83.83 KB, patch)
2016-11-10 18:43 PST, Alex Christensen
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews106 for mac-yosemite-wk2 (2.00 MB, application/zip)
2016-11-10 19:38 PST, Build Bot
no flags Details
Archive of layout-test-results from ews126 for ios-simulator-wk2 (865.86 KB, application/zip)
2016-11-10 19:49 PST, Build Bot
no flags Details
Patch (80.06 KB, patch)
2016-11-11 15:58 PST, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2016-07-15 14:16:55 PDT
Use SecurityOriginData as keys in StorageManager
Comment 1 Alex Christensen 2016-07-15 14:34:24 PDT
Created attachment 283792 [details]
Patch
Comment 2 WebKit Commit Bot 2016-07-15 14:36:14 PDT
Attachment 283792 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Storage/StorageManager.cpp:435:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Alex Christensen 2016-07-15 14:50:27 PDT
Created attachment 283794 [details]
Patch
Comment 4 WebKit Commit Bot 2016-07-15 14:51:45 PDT
Attachment 283794 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Storage/StorageManager.cpp:435:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Alex Christensen 2016-07-15 15:01:29 PDT
Created attachment 283796 [details]
Patch
Comment 6 WebKit Commit Bot 2016-07-15 15:03:01 PDT
Attachment 283796 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Storage/StorageManager.cpp:435:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Alex Christensen 2016-07-15 15:38:17 PDT
Created attachment 283803 [details]
Patch
Comment 8 WebKit Commit Bot 2016-07-15 15:39:39 PDT
Attachment 283803 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Storage/StorageManager.cpp:435:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Alex Christensen 2016-07-15 16:38:11 PDT
Created attachment 283813 [details]
Patch
Comment 10 WebKit Commit Bot 2016-07-15 16:40:16 PDT
Attachment 283813 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Storage/StorageManager.cpp:435:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Alex Christensen 2016-07-15 16:56:50 PDT
Created attachment 283816 [details]
Patch
Comment 12 WebKit Commit Bot 2016-07-15 16:58:14 PDT
Attachment 283816 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Storage/StorageManager.cpp:435:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Build Bot 2016-07-15 17:39:20 PDT
Comment on attachment 283816 [details]
Patch

Attachment 283816 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1688364

Number of test failures exceeded the failure limit.
Comment 14 Build Bot 2016-07-15 17:39:23 PDT
Created attachment 283828 [details]
Archive of layout-test-results from ews115 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 15 Alex Christensen 2016-07-15 17:49:01 PDT
Created attachment 283829 [details]
Patch
Comment 16 WebKit Commit Bot 2016-07-15 17:51:04 PDT
Attachment 283829 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Storage/StorageManager.cpp:435:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 17 Darin Adler 2016-07-17 09:53:04 PDT
Comment on attachment 283829 [details]
Patch

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

> Source/WebCore/page/SecurityOrigin.cpp:167
> +    // FIXME: We should only use this on the main thread.

I don’t understand this comment. What is "this" referring to? The SecurityOrigin::create function? The shouldTreatAsUniqueOrigin function?

What is the fix for the problem the comment is describing? Why are we not making the fix at this time?

> Source/WebCore/page/SecurityOrigin.cpp:169
>          Ref<SecurityOrigin> origin(adoptRef(*new SecurityOrigin));

We should change this line of code to:

    auto origin = adoptRef(*new SecurityOrigin);

> Source/WebCore/page/SecurityOriginData.cpp:110
> +bool operator==(const SecurityOrigin& a, const SecurityOriginData& b)
> +{
> +    return a.protocol() == b.protocol
> +        && a.host() == b.host
> +        && a.port() == b.port;
> +}
> +
> +bool operator==(const SecurityOriginData& a, const SecurityOrigin& b)
> +{
> +    return a.protocol == b.protocol()
> +        && a.host == b.host()
> +        && a.port == b.port();
> +}

It doesn’t seem right to use the == operation for this. There are so many other fields in a SecurityOrigin that this is ignoring. So this is some kind of matching operation, not an == operation.

> Source/WebCore/page/SecurityOriginData.h:59
> +WEBCORE_EXPORT bool operator==(const SecurityOrigin&, const SecurityOriginData&);
> +WEBCORE_EXPORT bool operator==(const SecurityOriginData&, const SecurityOrigin&);

We should find another solution to whatever problem we are solving by adding these == operators. There are other techniques for using keys of different types in collections.
Comment 18 Alex Christensen 2016-07-18 11:15:11 PDT
(In reply to comment #17)
> Comment on attachment 283829 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=283829&action=review
> 
> > Source/WebCore/page/SecurityOrigin.cpp:167
> > +    // FIXME: We should only use this on the main thread.
> 
> I don’t understand this comment. What is "this" referring to? The
> SecurityOrigin::create function? The shouldTreatAsUniqueOrigin function?
shouldTreatAsUniqueOrigin
> 
> What is the fix for the problem the comment is describing? Why are we not
> making the fix at this time?
There are still uses of shouldTreatAsUniqueOrigin on non-main threads that are outside the scope of this patch to fix.
Comment 19 Michael Catanzaro 2016-09-08 20:47:29 PDT
Comment on attachment 283829 [details]
Patch

I think you need to address Darin's comments before this is ready for review again. The operator== use is pretty concerning (marking objects are equal when they have different data fields, or when they're not even the same object)!
Comment 20 Alex Christensen 2016-11-10 16:01:47 PST
Created attachment 294430 [details]
Patch
Comment 21 Alex Christensen 2016-11-10 16:42:14 PST
Created attachment 294440 [details]
Patch
Comment 22 Alex Christensen 2016-11-10 16:51:55 PST
Created attachment 294442 [details]
Patch
Comment 23 Build Bot 2016-11-10 17:48:37 PST
Comment on attachment 294442 [details]
Patch

Attachment 294442 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2494160

Number of test failures exceeded the failure limit.
Comment 24 Build Bot 2016-11-10 17:48:40 PST
Created attachment 294450 [details]
Archive of layout-test-results from ews105 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 25 Build Bot 2016-11-10 17:59:51 PST
Comment on attachment 294442 [details]
Patch

Attachment 294442 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/2494167

Number of test failures exceeded the failure limit.
Comment 26 Build Bot 2016-11-10 17:59:55 PST
Created attachment 294451 [details]
Archive of layout-test-results from ews124 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews124  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 27 Daniel Bates 2016-11-10 18:09:05 PST
Comment on attachment 294442 [details]
Patch

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

> Source/WebKit2/UIProcess/Storage/StorageManager.cpp:534
> -                origins.add(WTFMove(origin));
> +                origins.add(origin);

Is this intentional?

> Source/WebKit2/UIProcess/Storage/StorageManager.cpp:577
> -            origins.add(WTFMove(origin));
> +            origins.add(origin);

Ditto.

> Source/WebKit2/UIProcess/Storage/StorageManager.cpp:581
> -                origins.add(WTFMove(origin));
> +                origins.add(origin);

Ditto.

> Source/WebKit2/UIProcess/Storage/StorageManager.cpp:691
> -        if (!origin->isSameSchemeHostPort(&area->securityOrigin()))
> +        if (!(origin == area->securityOrigin()))

This is a change in behavior. Is this intentional? I mean, SecurityOrigin::isSameSchemeHostPort() has special logic for file-based origins.

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:414
> +                    websiteData.entries.append(WebsiteData::Entry { WTFMove(origin).securityOrigin().ptr(), WebsiteDataType::MediaKeys, 0 });

Is the WTFMove() needed?

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:790
> +            for (auto origin : origins)

Did you mean to use "auto" to copy each SecurityOriginData object instead of "auto&"?
Comment 28 Alex Christensen 2016-11-10 18:43:09 PST
Created attachment 294458 [details]
Patch
Comment 29 Build Bot 2016-11-10 19:38:55 PST
Comment on attachment 294458 [details]
Patch

Attachment 294458 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2494697

Number of test failures exceeded the failure limit.
Comment 30 Build Bot 2016-11-10 19:38:59 PST
Created attachment 294460 [details]
Archive of layout-test-results from ews106 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 31 Build Bot 2016-11-10 19:49:40 PST
Comment on attachment 294458 [details]
Patch

Attachment 294458 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/2494704

Number of test failures exceeded the failure limit.
Comment 32 Build Bot 2016-11-10 19:49:43 PST
Created attachment 294461 [details]
Archive of layout-test-results from ews126 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews126  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 33 Alex Christensen 2016-11-10 22:58:18 PST
(In reply to comment #27)
> Comment on attachment 294442 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=294442&action=review
> 
> > Source/WebKit2/UIProcess/Storage/StorageManager.cpp:534
> > -                origins.add(WTFMove(origin));
> > +                origins.add(origin);
> 
> Is this intentional?
Yes, the type is now const SecurityOriginData& instead of RefPtr<SecurityOrigin>.
> > Source/WebKit2/UIProcess/Storage/StorageManager.cpp:691
> > -        if (!origin->isSameSchemeHostPort(&area->securityOrigin()))
> > +        if (!(origin == area->securityOrigin()))
> 
> This is a change in behavior. Is this intentional? I mean,
> SecurityOrigin::isSameSchemeHostPort() has special logic for file-based
> origins.
I won't change this behavior.  Thanks.
> 
> > Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:414
> > +                    websiteData.entries.append(WebsiteData::Entry { WTFMove(origin).securityOrigin().ptr(), WebsiteDataType::MediaKeys, 0 });
> 
> Is the WTFMove() needed?
No
> 
> > Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:790
> > +            for (auto origin : origins)
> 
> Did you mean to use "auto" to copy each SecurityOriginData object instead of
> "auto&"?
No, thanks.

There's also some other issue causing a lot of crashing.  Luckily it's easy to reproduce.
Comment 34 Alex Christensen 2016-11-11 15:58:33 PST
Created attachment 294557 [details]
Patch
Comment 35 Brady Eidson 2016-11-11 16:11:44 PST
Comment on attachment 294557 [details]
Patch

After EWS, sure.
Comment 36 WebKit Commit Bot 2016-11-11 17:21:29 PST
Comment on attachment 294557 [details]
Patch

Clearing flags on attachment: 294557

Committed r208633: <http://trac.webkit.org/changeset/208633>
Comment 37 WebKit Commit Bot 2016-11-11 17:21:36 PST
All reviewed patches have been landed.  Closing bug.