You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added a compile time assertion that forbids classes that offer WeakPtr
with no corresponding RefPtr or CheckedPtr
https://bugs.webkit.org/show_bug.cgi?id=273569
rdar://127296969
Reviewed by Ryosuke Niwa.
An object that offers WeakPtr with no corresponding RefPtr or CheckedPtr
is a dangerous contradiction. On the one hand, we know that it can be
deleted at any time. On the other hand, when we go to use it, we do
nothing to ensure its lifetime. This has been a source of use after
free / security bugs.
This patch adds a compile time assertion against future uses of this
anti-pattern. An explicit template specialization allow list maintains
existing uses. The allow list is a todo list for future deployment of
RefPtr or CheckedPtr.
This patch does not enforce correct usage of RefPtr or CheckedPtr; it
only enforces a rule that a class must at least offer RefPtr or
CheckedPtr if it offers WeakPtr.
In order to facilitate the allow list, I needed to
* Move some nested classes out-of-line, since C++ does not support
forward declaration or template specialization of nested classes
* Move some destructors out-of-line, since our compile time
assertion requires a complete type definition, and I didn't want to
increase #includes in headers
Canonical link: https://commits.webkit.org/278224@main
0 commit comments