Bug 199922

Summary: Add threading assertion to WeakPtr's operator->()
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web Template FrameworkAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, commit-queue, dbates, ews-watchlist, ggaren, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 200249, 200324    
Bug Blocks: 199517    
Attachments:
Description Flags
WIP Patch
none
Archive of layout-test-results from ews104 for mac-highsierra-wk2
none
Patch
none
Patch
none
Patch none

Description Chris Dumez 2019-07-18 16:07:36 PDT
Add threading assertion to WeakPtr's operator->().
Comment 1 Chris Dumez 2019-07-18 16:08:28 PDT
Created attachment 374424 [details]
WIP Patch
Comment 2 EWS Watchlist 2019-07-18 16:10:34 PDT
Attachment 374424 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/WeakPtr.h:75:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:77:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:83:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:85:  Should have a space between // and comment  [whitespace/comments] [4]
Total errors found: 4 in 1 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 EWS Watchlist 2019-07-18 17:26:54 PDT
Comment on attachment 374424 [details]
WIP Patch

Attachment 374424 [details] did not pass mac-wk2-ews (mac-wk2):
Output: https://webkit-queues.webkit.org/results/12769328

Number of test failures exceeded the failure limit.
Comment 4 EWS Watchlist 2019-07-18 17:26:56 PDT
Created attachment 374432 [details]
Archive of layout-test-results from ews104 for mac-highsierra-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-highsierra-wk2  Platform: Mac OS X 10.13.6
Comment 5 Chris Dumez 2019-07-29 18:39:23 PDT
Created attachment 375135 [details]
Patch
Comment 6 EWS Watchlist 2019-07-29 18:40:37 PDT
Attachment 375135 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/WeakPtr.h:75:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:77:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:83:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:85:  Should have a space between // and comment  [whitespace/comments] [4]
Total errors found: 4 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Geoffrey Garen 2019-07-30 09:10:14 PDT
Comment on attachment 375135 [details]
Patch

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

> Source/WTF/wtf/WeakPtr.h:65
> +        RELEASE_ASSERT(Thread::mayBeGCThread() || m_wasConstructedOnMainThread == isMainThread());

I think this needs to be a debug-only behavior. It's pretty expensive to turn every read from a pointer into a read from a thread-specific variable. We want WeakPtr to be "just as fast" as raw pointer, so we never have to have a performance vs security debate when we deploy WeakPtr.
Comment 8 Chris Dumez 2019-07-30 09:11:14 PDT
(In reply to Geoffrey Garen from comment #7)
> Comment on attachment 375135 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=375135&action=review
> 
> > Source/WTF/wtf/WeakPtr.h:65
> > +        RELEASE_ASSERT(Thread::mayBeGCThread() || m_wasConstructedOnMainThread == isMainThread());
> 
> I think this needs to be a debug-only behavior. It's pretty expensive to
> turn every read from a pointer into a read from a thread-specific variable.
> We want WeakPtr to be "just as fast" as raw pointer, so we never have to
> have a performance vs security debate when we deploy WeakPtr.

Well, obviously :) This is merely using RELEASE_ASSERT() so that EWS can catch cases that trip this assertion. This patch is NOT up for review :)
Comment 9 Geoffrey Garen 2019-07-30 09:16:55 PDT
Oh, duh :P
Comment 10 Chris Dumez 2019-08-01 07:36:43 PDT
Created attachment 375309 [details]
Patch
Comment 11 EWS Watchlist 2019-08-01 07:38:58 PDT
Attachment 375309 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/WeakPtr.h:75:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:77:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:83:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/WeakPtr.h:85:  Should have a space between // and comment  [whitespace/comments] [4]
Total errors found: 4 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 Chris Dumez 2019-08-01 08:56:55 PDT
Created attachment 375312 [details]
Patch
Comment 13 Chris Dumez 2019-08-01 09:53:30 PDT
Comment on attachment 375312 [details]
Patch

Patch is ready for review.
Comment 14 WebKit Commit Bot 2019-08-01 11:38:47 PDT
Comment on attachment 375312 [details]
Patch

Clearing flags on attachment: 375312

Committed r248113: <https://trac.webkit.org/changeset/248113>
Comment 15 WebKit Commit Bot 2019-08-01 11:38:49 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Radar WebKit Bug Importer 2019-08-01 11:39:23 PDT
<rdar://problem/53825085>