New issue
Advanced search Search tips

Issue 883909 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Sep 19
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 1
Type: Bug



Sign in to add a comment

WKHTTPCookieStore crashes on Cookies eg tests

Project Member Reported by mrefaat@chromium.org, Sep 13

Issue description

When WKHTTPSystemCookieStore flag is enabled.
Eg-test CookiesTestCase/testSwitchToMain crashes.

0   EarlGrey                            0x0000000120271023 grey_signalHandler + 227
1   libsystem_platform.dylib            0x0000000126016f5a _sigtramp + 26
2   ???                                 0x0000000000000000 0x0 + 0
3   ios_chrome_integration_egtests      0x000000010f192fb6 ___ZN3web23WKHTTPSystemCookieStore17DeleteCookieAsyncEP12NSHTTPCookieN4base12OnceCallbackIFvvEEE_block_invoke + 70
4   ios_chrome_integration_egtests      0x000000010f003131 _ZN4base8internal13FunctorTraitsIU8__strongU13block_pointerFvvEvE6InvokeIS4_JEEEvOT_DpOT0_ + 49
5   ios_chrome_integration_egtests      0x000000010f0030ed _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIU8__strongU13block_pointerFvvEJEEEvOT_DpOT0_ + 29
6   ios_chrome_integration_egtests      0x000000010f0030c1 _ZN4base8internal7InvokerINS0_9BindStateIU8__strongU13block_pointerFvvEJEEES3_E7RunImplIS5_NSt3__15tupleIJEEEJEEEvOT_OT0_NS9_16integer_sequenceImJXspT1_EEEE + 33
7   ios_chrome_integration_egtests      0x000000010f003019 _ZN4base8internal7InvokerINS0_9BindStateIU8__strongU13block_pointerFvvEJEEES3_E7RunOnceEPNS0_13BindStateBaseE + 57
8   ios_chrome_integration_egtests      0x000000010eb88bce _ZNO4base12OnceCallbackIFvvEE3RunEv + 78
9   ios_chrome_integration_egtests      0x0000000110529653 _ZN4base5debug13TaskAnnotator7RunTaskEPKcPNS_11PendingTaskE + 979
10  ios_chrome_integration_egtests      0x0000000110595d7f _ZN4base11MessageLoop7RunTaskEPNS_11PendingTaskE + 1199
11  ios_chrome_integration_egtests      0x000000011059625f _ZN4base11MessageLoop21DeferOrRunPendingTaskENS_11PendingTaskE + 95
12  ios_chrome_integration_egtests      0x000000011059671a _ZN4base11MessageLoop6DoWorkEv + 490
13  ios_chrome_integration_egtests      0x00000001108883a4 _ZN4base24MessagePumpCFRunLoopBase7RunWorkEv + 84
14  ios_chrome_integration_egtests      0x000000011088833c ___ZN4base24MessagePumpCFRunLoopBase13RunWorkSourceEPv_block_invoke + 28
15  ios_chrome_integration_egtests      0x000000011087ac61 _ZN4base3mac15CallWithEHFrameEU13block_pointerFvvE + 33
16  ios_chrome_integration_egtests      0x00000001108875f7 _ZN4base24MessagePumpCFRunLoopBase13RunWorkSourceEPv + 87
17  CoreFoundation                      0x000000011e2b7bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
18  CoreFoundation                      0x000000011e29c4af __CFRunLoopDoSources0 + 271
19  CoreFoundation                      0x000000011e29ba6f __CFRunLoopRun + 1263


 
Status: Started (was: Assigned)
Project Member

Comment 2 by bugdroid1@chromium.org, Sep 19

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1cc20e72617821bec929076a4c37f06d22486f0b

commit 1cc20e72617821bec929076a4c37f06d22486f0b
Author: mrefaat <mrefaat@chromium.org>
Date: Wed Sep 19 00:21:52 2018

Fix WKHTTPSystemCookieStore crash caused by object being deleted.

WKHTTPSystemCookieStore object can be deleted while there are some
pending callbacks, these callbacks needs to check if the object is alive
or not and based on that either early return or continue running.

We only need to keep a valid pointer to the WKHTTPCookieStore, the problem
that happens when the WKHTTPSystemCookieStore object is deleted is the pointer
it self become invalid, so the solution is to copy the weak pointer of
WKHTTPCookieStore inside the WKHTTPSystemCookieStore methods, so it remains
valid inside the blocks.

Bug:  883909 
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Ie499c368859ec4b604ea1cd97c971b7597bc5b57
Reviewed-on: https://chromium-review.googlesource.com/1225750
Reviewed-by: Eugene But <eugenebut@chromium.org>
Commit-Queue: Mohammad Refaat <mrefaat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592278}
[modify] https://crrev.com/1cc20e72617821bec929076a4c37f06d22486f0b/ios/net/cookies/system_cookie_store.h
[modify] https://crrev.com/1cc20e72617821bec929076a4c37f06d22486f0b/ios/web/net/cookies/wk_http_system_cookie_store.mm

Labels: Merge-Request-70
Status: Fixed (was: Started)
Project Member

Comment 4 by sheriffbot@chromium.org, Sep 19

Labels: -Merge-Request-70 Merge-Review-70 Hotlist-Merge-Review
This bug requires manual review: Less than 23 days to go before AppStore submit on M70
Please contact the milestone owner if you have questions.
Owners: benmason@(Android), kariahda@(iOS), geohsu@(ChromeOS), abdulsyed@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Are unit tests a possibility here? Or more eg tests? Also let's verify this on canary please.
Cc: subhashi...@chromium.org
Not sure why more eg tests, the existing eg tests actually caught the problem.
i verified on canary. subhashinik@ please take a look
The crash used to happen when clearing cookies happen while in incognito.

Tested on latest M71 build(71.0.3558.0) and on old version of M71(71.0.3549.0) on iPhone 6plus(iOS 10.3.3), iPhone 6splus(iOS 12 GM) and iPad Air(iOS 11.4.1)

mrefaat@ , we tried following cases to clear cookies in incognito tabs

1. Close all incognito tabs
2. Clear browsing data
3. Induce browser crash
4. Device reboot
5. App cold start

In all the cases cookies cleared with no crash

Note #1: Tested with main, persistent and session cookies

Could you please let us know if there are any other repo steps for the crash so that we will follow the same to replicate the issue.


The crash is hard to reproduce on the device, i had to do the steps on CookiesTestCase/testSwitchToMain at least 10 times for it to crash (however the eg test was crashing consistently) that's always the case when having a crash that is caused by memory deallocation.
Labels: -Merge-Review-70 Merge-Approved-70
Status: Verified (was: Fixed)
Per comment 7, assuming this is verified?

Approved.
Project Member

Comment 10 by bugdroid1@chromium.org, Sep 27

Labels: -merge-approved-70 merge-merged-3538
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b54aaaab9b787315580cce48ddf716a62264595e

commit b54aaaab9b787315580cce48ddf716a62264595e
Author: mrefaat <mrefaat@chromium.org>
Date: Thu Sep 27 03:12:18 2018

[Merge to M70] Fix WKHTTPSystemCookieStore crash caused by object being deleted.

WKHTTPSystemCookieStore object can be deleted while there are some
pending callbacks, these callbacks needs to check if the object is alive
or not and based on that either early return or continue running.

We only need to keep a valid pointer to the WKHTTPCookieStore, the problem
that happens when the WKHTTPSystemCookieStore object is deleted is the pointer
it self become invalid, so the solution is to copy the weak pointer of
WKHTTPCookieStore inside the WKHTTPSystemCookieStore methods, so it remains
valid inside the blocks.

(cherry picked from commit 1cc20e72617821bec929076a4c37f06d22486f0b)

Bug:  883909 
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Ie499c368859ec4b604ea1cd97c971b7597bc5b57
Reviewed-on: https://chromium-review.googlesource.com/1225750
Reviewed-by: Eugene But <eugenebut@chromium.org>
Commit-Queue: Mohammad Refaat <mrefaat@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#592278}
Reviewed-on: https://chromium-review.googlesource.com/1246593
Cr-Commit-Position: refs/branch-heads/3538@{#698}
Cr-Branched-From: 79f7c91a2b2a2932cd447fa6f865cb6662fa8fa6-refs/heads/master@{#587811}
[modify] https://crrev.com/b54aaaab9b787315580cce48ddf716a62264595e/ios/net/cookies/system_cookie_store.h
[modify] https://crrev.com/b54aaaab9b787315580cce48ddf716a62264595e/ios/web/net/cookies/wk_http_system_cookie_store.mm

Labels: Merge-Merged-70-3538
The following revision refers to this bug: 
https://chromium.googlesource.com/chromium/src.git/+/b54aaaab9b787315580cce48ddf716a62264595e

Commit: b54aaaab9b787315580cce48ddf716a62264595e
Author: mrefaat@chromium.org
Commiter: mrefaat@chromium.org
Date: 2018-09-27 03:12:18 +0000 UTC

[Merge to M70] Fix WKHTTPSystemCookieStore crash caused by object being deleted.

WKHTTPSystemCookieStore object can be deleted while there are some
pending callbacks, these callbacks needs to check if the object is alive
or not and based on that either early return or continue running.

We only need to keep a valid pointer to the WKHTTPCookieStore, the problem
that happens when the WKHTTPSystemCookieStore object is deleted is the pointer
it self become invalid, so the solution is to copy the weak pointer of
WKHTTPCookieStore inside the WKHTTPSystemCookieStore methods, so it remains
valid inside the blocks.

(cherry picked from commit 1cc20e72617821bec929076a4c37f06d22486f0b)

Bug:  883909 
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Ie499c368859ec4b604ea1cd97c971b7597bc5b57
Reviewed-on: https://chromium-review.googlesource.com/1225750
Reviewed-by: Eugene But <eugenebut@chromium.org>
Commit-Queue: Mohammad Refaat <mrefaat@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#592278}
Reviewed-on: https://chromium-review.googlesource.com/1246593
Cr-Commit-Position: refs/branch-heads/3538@{#698}
Cr-Branched-From: 79f7c91a2b2a2932cd447fa6f865cb6662fa8fa6-refs/heads/master@{#587811}

Sign in to add a comment