WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
185041
[WKHTTPCookieStore getAllCookies] returns inconsistent creation time
https://bugs.webkit.org/show_bug.cgi?id=185041
Summary
[WKHTTPCookieStore getAllCookies] returns inconsistent creation time
Sihui Liu
Reported
2018-04-26 13:01:08 PDT
Calling getAllCookies multiple times would return different creation time/expiration time for the same cookie.
Attachments
Patch
(5.81 KB, patch)
2018-04-30 20:01 PDT
,
Sihui Liu
no flags
Details
Formatted Diff
Diff
Patch
(3.61 KB, patch)
2018-05-01 12:02 PDT
,
Sihui Liu
no flags
Details
Formatted Diff
Diff
Patch
(3.53 KB, patch)
2018-05-01 16:29 PDT
,
Sihui Liu
no flags
Details
Formatted Diff
Diff
Patch
(5.58 KB, patch)
2018-05-07 23:06 PDT
,
Sihui Liu
no flags
Details
Formatted Diff
Diff
Patch
(5.92 KB, patch)
2018-05-25 11:01 PDT
,
Sihui Liu
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Sihui Liu
Comment 1
2018-04-26 13:02:40 PDT
<
rdar://problem/34684214
>
Sihui Liu
Comment 2
2018-04-30 20:01:30 PDT
Created
attachment 339171
[details]
Patch
Chris Dumez
Comment 3
2018-05-01 09:30:30 PDT
Comment on
attachment 339171
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=339171&action=review
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:335 > + NSMutableDictionary *cookieProperties = [[NSMutableDictionary alloc] init];
Doesn't this leak? Should probably use RetainPtr and adoptNS().
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:357 > + [cookies release];
Should probably use RetainPtr instead of manual release.
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:359 > + sleep(5_s);
Do we need to sleep for that long? We do not like slow tests in general.
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:367 > + ASSERT_EQ(cookies.count, 1u);
I believe this is reversed: ASSERT_EQ(1U, cookies.count);
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:371 > + [cookies release];
Should probably use RetainPtr instead of manual release.
Geoffrey Garen
Comment 4
2018-05-01 09:44:40 PDT
Comment on
attachment 339171
[details]
Patch r- I agree with Chris. Let's discuss Cocoa retain/release in more detail when we have a chance.
Sihui Liu
Comment 5
2018-05-01 12:02:53 PDT
Created
attachment 339212
[details]
Patch
Geoffrey Garen
Comment 6
2018-05-01 15:21:09 PDT
Comment on
attachment 339212
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=339212&action=review
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:348 > + *cookiesPtr = [nsCookies retain];
RetainPtr is a smart pointer <
https://en.wikipedia.org/wiki/Smart_pointer
> that automatically retains and releases the pointer it holds. The act of assignment is an implicit retain of the new value and release of the old value, so please remove this explicit retain, which is an extra retain, and therefore a memory leak. Also, you can just lambda capture &cookies and use "cookies" by name, rather than capturing cookiesPtr = &cookies. I think that's simpler.
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:356 > + sleep(1_s);
What is the resolution of creation time? If it's milliseconds, then you can reduce this sleep to something like 10ms. It's good to make tests as fast as possible because we have tens of thousands of them.
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:359 > + *cookiesPtr = [nsCookies retain];
Ditto.
Sihui Liu
Comment 7
2018-05-01 16:29:32 PDT
Created
attachment 339240
[details]
Patch
Sihui Liu
Comment 8
2018-05-01 16:37:29 PDT
(In reply to Geoffrey Garen from
comment #6
)
> Comment on
attachment 339212
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=339212&action=review
> > > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:348 > > + *cookiesPtr = [nsCookies retain]; > > RetainPtr is a smart pointer <
https://en.wikipedia.org/wiki/Smart_pointer
> > that automatically retains and releases the pointer it holds. The act of > assignment is an implicit retain of the new value and release of the old > value, so please remove this explicit retain, which is an extra retain, and > therefore a memory leak. > > Also, you can just lambda capture &cookies and use "cookies" by name, rather > than capturing cookiesPtr = &cookies. I think that's simpler. >
Done. Lambda capture seems to pass non-static params by value. But I realized we don't need a cookies variable here...
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:356 > > + sleep(1_s); > > What is the resolution of creation time? If it's milliseconds, then you can > reduce this sleep to something like 10ms. > > It's good to make tests as fast as possible because we have tens of > thousands of them. >
It's measured in seconds.
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:359 > > + *cookiesPtr = [nsCookies retain]; > > Ditto.
Done.
Geoffrey Garen
Comment 9
2018-05-07 19:49:25 PDT
Comment on
attachment 339240
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=339240&action=review
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:351 > + RetainPtr<NSNumber> creationTime = nil; > + [globalCookieStore getAllCookies:[creationTimePtr = &creationTime](NSArray<NSHTTPCookie *> *cookies) { > + ASSERT_EQ(1u, cookies.count); > + *creationTimePtr = [cookies objectAtIndex:0].properties[@"Created"]; > + gotFlag = true; > + }];
I think it should work to do "[globalCookieStore getAllCookies:[&](...) { ... creationTime = ... }". Then you capture the creationTime RetainPtr by reference, and assign to it.
> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:359 > + RetainPtr<NSNumber> creationTime2 = [cookies objectAtIndex:0].properties[@"Created"];
You can use NSNumber * here instead of RetainPtr<NSNumber> because objectAtIndex returns an autoreleased value, which remains live within this scope. <
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html#//apple_ref/doc/uid/20000047-CJBFBEDI
>
Sihui Liu
Comment 10
2018-05-07 23:06:30 PDT
Created
attachment 339803
[details]
Patch
Geoffrey Garen
Comment 11
2018-05-08 10:17:44 PDT
Comment on
attachment 339803
[details]
Patch r=me
WebKit Commit Bot
Comment 12
2018-05-08 10:44:08 PDT
Comment on
attachment 339803
[details]
Patch Clearing flags on attachment: 339803 Committed
r231491
: <
https://trac.webkit.org/changeset/231491
>
WebKit Commit Bot
Comment 13
2018-05-08 10:44:09 PDT
All reviewed patches have been landed. Closing bug.
WebKit Commit Bot
Comment 14
2018-05-08 11:22:45 PDT
Re-opened since this is blocked by
bug 185434
Geoffrey Garen
Comment 15
2018-05-24 13:12:42 PDT
If we need a CF change to get the behavior we want, then we should conditionalize this new behavior and exclude it from OS's that lack the change we need.
Sihui Liu
Comment 16
2018-05-25 11:01:46 PDT
Created
attachment 341302
[details]
Patch
Geoffrey Garen
Comment 17
2018-05-25 11:08:31 PDT
Comment on
attachment 341302
[details]
Patch r=me
WebKit Commit Bot
Comment 18
2018-05-25 11:35:18 PDT
Comment on
attachment 341302
[details]
Patch Clearing flags on attachment: 341302 Committed
r232191
: <
https://trac.webkit.org/changeset/232191
>
WebKit Commit Bot
Comment 19
2018-05-25 11:35:20 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug