Bug 200189 - Try fixing crash at com.apple.WebKit.Networking: NetworkProcess::setSharedHTTPCookieStorage
Summary: Try fixing crash at com.apple.WebKit.Networking: NetworkProcess::setSharedHTT...
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: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-07-26 19:14 PDT by Sihui Liu
Modified: 2019-07-29 17:22 PDT (History)
6 users (show)

See Also:


Attachments
Patch (3.81 KB, patch)
2019-07-28 23:24 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (5.33 KB, patch)
2019-07-29 12:42 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (5.40 KB, patch)
2019-07-29 13:11 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (5.63 KB, patch)
2019-07-29 16:54 PDT, 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 2019-07-26 19:14:59 PDT
<rdar://problem/41325767>
Comment 1 Sihui Liu 2019-07-28 23:24:30 PDT
Created attachment 375064 [details]
Patch
Comment 2 Chris Dumez 2019-07-29 09:56:24 PDT
Comment on attachment 375064 [details]
Patch

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

> Source/WebKit/UIProcess/WebProcessPool.cpp:624
> +        swap(m_networkProcess, networkProcess);

Indentation problem?
Also, why swap instead of a WTFMove()?

If you're right about the reason for the crash, wouldn't it mean that ensureNetworkProcess() is now likely to re-enter and re-construct m_networkProcess?
Comment 3 Sihui Liu 2019-07-29 12:42:54 PDT
Created attachment 375092 [details]
Patch
Comment 4 Chris Dumez 2019-07-29 13:06:00 PDT
Comment on attachment 375092 [details]
Patch

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

> Source/WebKit/UIProcess/WebProcessPool.cpp:475
> +    if (!RunLoop::isMain()) {

Can we at lease add a ASSERT(RunLoop::isMain()); debug assertion?

> Source/WebKit/UIProcess/WebProcessPool.cpp:476
> +        callOnMainRunLoopAndWait([this] {

I am not convinced |this| is guaranteed to still be alive by the time you get to the main runloop. We likely this to protect/ref it in the lambda.
Comment 5 Sihui Liu 2019-07-29 13:11:06 PDT
(In reply to Chris Dumez from comment #4)
> Comment on attachment 375092 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=375092&action=review
> 
> > Source/WebKit/UIProcess/WebProcessPool.cpp:475
> > +    if (!RunLoop::isMain()) {
> 
> Can we at lease add a ASSERT(RunLoop::isMain()); debug assertion?

Okay.

> 
> > Source/WebKit/UIProcess/WebProcessPool.cpp:476
> > +        callOnMainRunLoopAndWait([this] {
> 
> I am not convinced |this| is guaranteed to still be alive by the time you
> get to the main runloop. We likely this to protect/ref it in the lambda.

Will add.
Comment 6 Sihui Liu 2019-07-29 13:11:51 PDT
Created attachment 375093 [details]
Patch
Comment 7 Chris Dumez 2019-07-29 13:13:06 PDT
Comment on attachment 375093 [details]
Patch

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

r=me

> Source/WebKit/UIProcess/WebProcessPool.cpp:476
> +    if (!RunLoop::isMain()) {

We may want to put in a comment explaining this is a temporary workaround for apps using our API on non-main threads.
Comment 8 Geoffrey Garen 2019-07-29 13:32:35 PDT
Comment on attachment 375093 [details]
Patch

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

>> Source/WebKit/UIProcess/WebProcessPool.cpp:476
>> +    if (!RunLoop::isMain()) {
> 
> We may want to put in a comment explaining this is a temporary workaround for apps using our API on non-main threads.

Yes, let's please do that, with a link to a bug report. That way, future programmers have context, and will know under what conditions they can remove this / what they should test if they remove this.
Comment 9 Sihui Liu 2019-07-29 15:03:13 PDT
(In reply to Geoffrey Garen from comment #8)
> Comment on attachment 375093 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=375093&action=review
> 
> >> Source/WebKit/UIProcess/WebProcessPool.cpp:476
> >> +    if (!RunLoop::isMain()) {
> > 
> > We may want to put in a comment explaining this is a temporary workaround for apps using our API on non-main threads.
> 
> Yes, let's please do that, with a link to a bug report. That way, future
> programmers have context, and will know under what conditions they can
> remove this / what they should test if they remove this.

Sure, will add after the last bot turns green.
Comment 10 Sihui Liu 2019-07-29 16:54:34 PDT
Created attachment 375127 [details]
Patch for landing
Comment 11 WebKit Commit Bot 2019-07-29 17:21:51 PDT
Comment on attachment 375127 [details]
Patch for landing

Clearing flags on attachment: 375127

Committed r247933: <https://trac.webkit.org/changeset/247933>
Comment 12 WebKit Commit Bot 2019-07-29 17:21:52 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Radar WebKit Bug Importer 2019-07-29 17:22:15 PDT
<rdar://problem/53687367>