Bug 236844 - Add assertion that no two sessions share the same general storage directory
Summary: Add assertion that no two sessions share the same general storage directory
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Website Storage (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-18 09:54 PST by Sihui Liu
Modified: 2022-03-02 11:01 PST (History)
3 users (show)

See Also:


Attachments
Patch (4.75 KB, patch)
2022-02-18 10:34 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (5.96 KB, patch)
2022-02-18 15:12 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (5.93 KB, patch)
2022-02-18 16:54 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (5.46 KB, patch)
2022-02-28 15:40 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (5.51 KB, patch)
2022-02-28 16:05 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (23.25 KB, patch)
2022-03-01 19:27 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (23.23 KB, patch)
2022-03-01 23:16 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (23.18 KB, patch)
2022-03-02 09:47 PST, Sihui Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sihui Liu 2022-02-18 09:54:17 PST
...
Comment 1 Sihui Liu 2022-02-18 10:34:57 PST
Created attachment 452539 [details]
Patch
Comment 2 Sihui Liu 2022-02-18 15:12:14 PST
Created attachment 452586 [details]
Patch
Comment 3 Chris Dumez 2022-02-18 16:46:09 PST
Comment on attachment 452586 [details]
Patch

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

r=me

> Source/WebKit/ChangeLog:3
> +        Add assertion that no two network session share the same storage path

sessions (plural)

> Source/WebKit/ChangeLog:8
> +        Each NetworkStorageManager has its own queue and access the storage files on that queue, so we can't have two

accesses

> Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp:115
> +    static NeverDestroyed<HashSet<String>> paths;

I just learned today that you can use MainThreadNeverDestroyed (and drop your main thread assertion above).
Comment 4 Sihui Liu 2022-02-18 16:54:06 PST
Created attachment 452609 [details]
Patch for landing
Comment 5 EWS 2022-02-18 20:15:19 PST
Committed r290196 (247524@main): <https://commits.webkit.org/247524@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452609 [details].
Comment 6 Radar WebKit Bug Importer 2022-02-18 20:16:17 PST
<rdar://problem/89178566>
Comment 7 Chris Dumez 2022-02-19 13:43:01 PST
Reverted r290196 for reason:

Caused Network Process crashes <rdar://89190571>

Committed r290214 (247542@trunk): <https://commits.webkit.org/247542@trunk>
Comment 8 Sihui Liu 2022-02-28 15:40:09 PST
Created attachment 453443 [details]
Patch
Comment 9 Chris Dumez 2022-02-28 15:50:04 PST
Comment on attachment 453443 [details]
Patch

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

> Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:211
> +    HashMap<String, PAL::SessionID> directoriesBySession;

This name seems wrong. If something says "BySession", then I'd expect the session to be the HashMap key, not the value.
Maybe this could be named something like: "directorySessions" or "sessionForDirectory"

> Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:216
> +                RELEASE_ASSERT_WITH_MESSAGE(directoriesBySession.add(directory, sessionID).isNewEntry, "GeneralStorageDirectory for session '%llu' is already in use by session '%llu'", directoriesBySession.get(directory).toUInt64(), sessionID.toUInt64());

We're supposed to use PRIu64, not %llu to print 64bit integers to be friendly to Linux ports. Looks like this code may not build on Linux but I think it I still good practice.
Comment 10 Sihui Liu 2022-02-28 16:05:27 PST
Created attachment 453446 [details]
Patch
Comment 11 Sihui Liu 2022-02-28 16:06:19 PST
(In reply to Chris Dumez from comment #9)
> Comment on attachment 453443 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=453443&action=review
> 
> > Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:211
> > +    HashMap<String, PAL::SessionID> directoriesBySession;
> 
> This name seems wrong. If something says "BySession", then I'd expect the
> session to be the HashMap key, not the value.
> Maybe this could be named something like: "directorySessions" or
> "sessionForDirectory"

Changed to sessionForDirectory.

> 
> > Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:216
> > +                RELEASE_ASSERT_WITH_MESSAGE(directoriesBySession.add(directory, sessionID).isNewEntry, "GeneralStorageDirectory for session '%llu' is already in use by session '%llu'", directoriesBySession.get(directory).toUInt64(), sessionID.toUInt64());
> 
> We're supposed to use PRIu64, not %llu to print 64bit integers to be
> friendly to Linux ports. Looks like this code may not build on Linux but I
> think it I still good practice.

Sure, changed to PRIu64.
Comment 12 Sihui Liu 2022-03-01 19:27:27 PST
Created attachment 453563 [details]
Patch
Comment 13 Sihui Liu 2022-03-01 23:16:12 PST
Created attachment 453573 [details]
Patch
Comment 14 EWS 2022-03-02 09:42:19 PST
ChangeLog entry in Tools/ChangeLog contains OOPS!.
Comment 15 Sihui Liu 2022-03-02 09:47:28 PST
Created attachment 453627 [details]
Patch for landing
Comment 16 EWS 2022-03-02 11:01:18 PST
Committed r290739 (247985@main): <https://commits.webkit.org/247985@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453627 [details].