WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
224412
WebProcessPool should store Vector<Ref<WebProcessProxy>> instead of Vector<RefPtr>
https://bugs.webkit.org/show_bug.cgi?id=224412
Summary
WebProcessPool should store Vector<Ref<WebProcessProxy>> instead of Vector<Re...
Alex Christensen
Reported
2021-04-10 20:46:29 PDT
WebProcessPool should store Vector<Ref<WebProcessProxy>> instead of Vector<RefPtr>
Attachments
Patch
(21.51 KB, patch)
2021-04-10 20:47 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(25.20 KB, patch)
2021-04-10 23:10 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(21.50 KB, patch)
2021-04-13 14:54 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Alex Christensen
Comment 1
2021-04-10 20:47:25 PDT
Created
attachment 425698
[details]
Patch
Chris Dumez
Comment 2
2021-04-10 21:23:07 PDT
Comment on
attachment 425698
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=425698&action=review
R=me with nits
> Source/WebKit/UIProcess/WebProcessPool.cpp:513 > + Vector<Ref<WebProcessProxy>> processes = m_processes;
Auto ?
> Source/WebKit/UIProcess/WebProcessPool.cpp:904 > + Vector<Ref<WebProcessProxy>> processes = m_processes;
Auto?
> Source/WebKit/UIProcess/WebProcessPool.cpp:1503 > + Vector<Ref<WebProcessProxy>> processes = m_processes;
Auto?
Alex Christensen
Comment 3
2021-04-10 23:10:25 PDT
Created
attachment 425700
[details]
Patch
Alex Christensen
Comment 4
2021-04-10 23:15:34 PDT
Comment on
attachment 425700
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=425700&action=review
> Source/WebCore/ChangeLog:11 > + Remove the Ref comparators for Ref<SharedBuffer> which were only used in tests.
This isn't true.
Alex Christensen
Comment 5
2021-04-13 14:54:43 PDT
(In reply to Chris Dumez from
comment #2
)
> > Source/WebKit/UIProcess/WebProcessPool.cpp:1503 > > + Vector<Ref<WebProcessProxy>> processes = m_processes; > > Auto?
I feel like it's important to have the type explicit here to indicate that we are copying the Vector<Ref> instead of making a reference or something that wouldn't.
Alex Christensen
Comment 6
2021-04-13 14:54:50 PDT
Created
attachment 425918
[details]
Patch
EWS
Comment 7
2021-04-13 15:48:17 PDT
Committed
r275916
(
236480@main
): <
https://commits.webkit.org/236480@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 425918
[details]
.
Radar WebKit Bug Importer
Comment 8
2021-04-13 15:49:31 PDT
<
rdar://problem/76614575
>
Darin Adler
Comment 9
2021-04-13 16:36:54 PDT
Comment on
attachment 425918
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=425918&action=review
> Source/WTF/wtf/Ref.h:326 > +template<typename T, typename U, typename V, typename W> > +inline bool operator==(const Ref<T, U>& a, const Ref<V, W>& b) > +{ > + return a.ptr() == b.ptr(); > +} > + > +template<typename T, typename U, typename V> > +inline bool operator==(const Ref<T, U>& a, V& b) > +{ > + return a.ptr() == &b; > +} > + > +template<typename T, typename U, typename V> > +inline bool operator==(T& a, const Ref<U, V>& b) > +{ > + return &a == b.ptr(); > +} > + > +template<typename T, typename U, typename V, typename W> > +inline bool operator!=(const Ref<T, U>& a, const Ref<V, W>& b) > +{ > + return a.ptr() != b.ptr(); > +} > + > +template<typename T, typename U, typename V> > +inline bool operator!=(const Ref<T, U>& a, V& b) > +{ > + return a.ptr() != &b; > +} > + > +template<typename T, typename U, typename V> > +inline bool operator!=(T& a, const Ref<U, V>& b) > +{ > + return &a != b.ptr(); > +}
When originally creating Ref<> we intentionally omitted these function templates, because comparing two references with == compares the *values*, not the pointers. So we thought it was ambiguous whether a == b should be a.ptr() == b.ptr() or a.get() == b.get(), which are different. I know this is handy if you think of Ref as a RefPtr that can never be null. But less logical if you think of it as a kind of reference.
Alex Christensen
Comment 10
2021-04-13 16:39:18 PDT
I could see that confusion when comparing a Ref<T> and a T&. Do you think it's also confusing when comparing a Ref<T> and another Ref<T>?
Darin Adler
Comment 11
2021-04-13 16:44:22 PDT
(In reply to Alex Christensen from
comment #10
)
> Do you think > it's also confusing when comparing a Ref<T> and another Ref<T>?
I did back when we made the original call. Not sure how I feel about it now.
Chris Dumez
Comment 12
2021-04-13 16:46:26 PDT
(In reply to Darin Adler from
comment #9
)
> Comment on
attachment 425918
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=425918&action=review
> > > Source/WTF/wtf/Ref.h:326 > > +template<typename T, typename U, typename V, typename W> > > +inline bool operator==(const Ref<T, U>& a, const Ref<V, W>& b) > > +{ > > + return a.ptr() == b.ptr(); > > +} > > + > > +template<typename T, typename U, typename V> > > +inline bool operator==(const Ref<T, U>& a, V& b) > > +{ > > + return a.ptr() == &b; > > +} > > + > > +template<typename T, typename U, typename V> > > +inline bool operator==(T& a, const Ref<U, V>& b) > > +{ > > + return &a == b.ptr(); > > +} > > + > > +template<typename T, typename U, typename V, typename W> > > +inline bool operator!=(const Ref<T, U>& a, const Ref<V, W>& b) > > +{ > > + return a.ptr() != b.ptr(); > > +} > > + > > +template<typename T, typename U, typename V> > > +inline bool operator!=(const Ref<T, U>& a, V& b) > > +{ > > + return a.ptr() != &b; > > +} > > + > > +template<typename T, typename U, typename V> > > +inline bool operator!=(T& a, const Ref<U, V>& b) > > +{ > > + return &a != b.ptr(); > > +} > > When originally creating Ref<> we intentionally omitted these function > templates, because comparing two references with == compares the *values*, > not the pointers. So we thought it was ambiguous whether a == b should be > a.ptr() == b.ptr() or a.get() == b.get(), which are different. > > I know this is handy if you think of Ref as a RefPtr that can never be null. > But less logical if you think of it as a kind of reference.
I think we went the way of "RefPtr that cannot be null" instead of "kind of a reference" when we made Ref<> copyable too.
Jer Noble
Comment 13
2022-02-25 09:44:41 PST
(In reply to Chris Dumez from
comment #12
)
> (In reply to Darin Adler from
comment #9
) > > Comment on
attachment 425918
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=425918&action=review
> > > > > Source/WTF/wtf/Ref.h:326 > > > +template<typename T, typename U, typename V, typename W> > > > +inline bool operator==(const Ref<T, U>& a, const Ref<V, W>& b) > > > +{ > > > + return a.ptr() == b.ptr(); > > > +} > > > + > > > +template<typename T, typename U, typename V> > > > +inline bool operator==(const Ref<T, U>& a, V& b) > > > +{ > > > + return a.ptr() == &b; > > > +} > > > + > > > +template<typename T, typename U, typename V> > > > +inline bool operator==(T& a, const Ref<U, V>& b) > > > +{ > > > + return &a == b.ptr(); > > > +} > > > + > > > +template<typename T, typename U, typename V, typename W> > > > +inline bool operator!=(const Ref<T, U>& a, const Ref<V, W>& b) > > > +{ > > > + return a.ptr() != b.ptr(); > > > +} > > > + > > > +template<typename T, typename U, typename V> > > > +inline bool operator!=(const Ref<T, U>& a, V& b) > > > +{ > > > + return a.ptr() != &b; > > > +} > > > + > > > +template<typename T, typename U, typename V> > > > +inline bool operator!=(T& a, const Ref<U, V>& b) > > > +{ > > > + return &a != b.ptr(); > > > +} > > > > When originally creating Ref<> we intentionally omitted these function > > templates, because comparing two references with == compares the *values*, > > not the pointers. So we thought it was ambiguous whether a == b should be > > a.ptr() == b.ptr() or a.get() == b.get(), which are different. > > > > I know this is handy if you think of Ref as a RefPtr that can never be null. > > But less logical if you think of it as a kind of reference. > > I think we went the way of "RefPtr that cannot be null" instead of "kind of > a reference" when we made Ref<> copyable too.
This actually caused a real, user facing bug. This changed the behavior of a check inside the EME code to cause a pointer-equality test rather than a content test, and that test now fails, causing key rotations to fail.
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