Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REGRESSION(r294381): [ Debug ] TestWebKitAPI.WebKit.CookieObserverCrash is a constant crash #816

Merged
merged 0 commits into from May 26, 2022

Conversation

szewai
Copy link
Contributor

@szewai szewai commented May 20, 2022

3ba1f41

REGRESSION(r294381): [ Debug ] TestWebKitAPI.WebKit.CookieObserverCrash is a constant crash
https://bugs.webkit.org/show_bug.cgi?id=240595

Reviewed by Alex Christensen.

The crash is an assertion failure. The assertion ensures that WebCookieManagerProxy has no cookies observer when it gets
destroyed. The assertion was valid when it was added, since WKHTTPCookieStore does not outlive WebKit::WebsiteDataStore
(r219550), and observers will be removed when WKHTTPCookieStore is deallocated. Since r279074, WKHTTPCookieStore can
outlive WebKit::WebsiteDataStore -- it holds a weak reference to WebKit::WebsiteDataStore instead of a strong reference,
so the assertion does not hold.

* Source/WebKit/UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::~WebCookieManagerProxy):

Canonical link: https://commits.webkit.org/250992@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294860 268f45cc-cd09-0410-ab3c-d52691b4dbfc

@szewai szewai self-assigned this May 20, 2022
@szewai szewai added New Bugs Unclassified bugs are placed in this component until the correct component can be determined. WebKit Nightly Build labels May 20, 2022
@@ -49,7 +49,8 @@ WebCookieManagerProxy::~WebCookieManagerProxy()
{
if (m_networkProcess)
m_networkProcess->removeMessageReceiver(Messages::WebCookieManagerProxy::messageReceiverName());
ASSERT(m_cookieObservers.isEmpty());
if (!m_cookieObservers.isEmpty())
RELEASE_LOG(Storage, "WebCookieManagerProxy::~WebCookieManagerProxy %u cookie observers will be invalidated", m_cookieObservers.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean that the API client may still have a registered cookie observer and yet no longer receive any notifications because the WebCookieManagerProxy was destroyed? Wouldn't this be a bug?

Seems like if the clients is monitoring cookies, they should be getting updates until they unregister their observer.

Copy link
Contributor Author

@szewai szewai May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just like the failed test. If client has a registered cookie observer but WebsiteDataStore is destroyed, the observer will not get any notification. It looks reasonable to me that client does not get notification about cookies of an ephemeral session if the session is destroyed? (The ref chains are: WKWebsiteDataStore => WebsiteDataStore => NetworkProcessProxy => WebCookieManagerProxy and WKHttpCookieStore => API::HTTPCookieStore -> WebCookieManagerProxy).
I am not sure how this API is supposed to work originally, at least according to current implementation, the assertion seems to not hold.

@cdumez
Copy link
Contributor

cdumez commented May 20, 2022

I'll defer Brady/Alex here. This seems like suspicious API behavior to me and a regression from your recent refactoring since the assertion wasn't hitting before. Fixing the assertion hit by removing the assertion is always suspicious too.

@szewai
Copy link
Contributor Author

szewai commented May 20, 2022

I'll defer Brady/Alex here. This seems like suspicious API behavior to me and a regression from your recent refactoring since the assertion wasn't hitting before. Fixing the assertion hit by removing the assertion is always suspicious too.

The assertion wasn't hit because WebsiteDataStore was held alive by WebProcessProxy, so WebsiteDataStore is not destroyed as expected during the test.

@cdumez
Copy link
Contributor

cdumez commented May 20, 2022

@beidson Added this test here:
Crash when a WKHTTPCookieStore outlives its owning WKWebsiteDataStore.
rdar://problem/33341730 and https://bugs.webkit.org/show_bug.cgi?id=174574

He intentionally made sure that the APIHTTPCookieStore would keep its data store alive.

@szewai
Copy link
Contributor Author

szewai commented May 20, 2022

@beidson Added this test here: Crash when a WKHTTPCookieStore outlives its owning WKWebsiteDataStore. rdar://problem/33341730 and https://bugs.webkit.org/show_bug.cgi?id=174574

He intentionally made sure that the APIHTTPCookieStore would keep its data store alive.

Yes, as mentioned in the commit message: this statement that APIHTTPCookieStore would keep its data store alive is no longer valid after https://trac.webkit.org/changeset/279074/webkit (from @achristensen07, reviewed by @cdumez ).
And the test passed because it doesn't execute what it wants to test (at least right before my change): WebsiteDataStore gets destroyed.

Copy link
Contributor

@achristensen07 achristensen07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine. We should really just completely remove WebCookieManagerProxy.

@szewai szewai added the merge-queue Applied to send a pull request to merge-queue label May 25, 2022
@webkit-early-warning-system webkit-early-warning-system merged commit 3ba1f41 into WebKit:main May 26, 2022
@webkit-early-warning-system
Copy link
Collaborator

Committed r294860 (250992@main): https://commits.webkit.org/250992@main

Reviewed commits have been landed. Closing PR #816 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system removed the merge-queue Applied to send a pull request to merge-queue label May 26, 2022
@szewai szewai deleted the eng/bug_240595 branch July 5, 2022 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Bugs Unclassified bugs are placed in this component until the correct component can be determined.
Projects
None yet
4 participants