[Webkit-unassigned] [Bug 195605] New: makeWeakPtr isn't thread-safe

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Mar 11 21:53:32 PDT 2019


https://bugs.webkit.org/show_bug.cgi?id=195605

            Bug ID: 195605
           Summary: makeWeakPtr isn't thread-safe
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Template Framework
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: Hironori.Fujii at sony.com
                CC: achristensen at apple.com, darin at apple.com,
                    koivisto at iki.fi, rniwa at webkit.org

makeWeakPtr isn't thread-safe even though it is called in non main threads.
This can be problem if multiple threads would call makeWeakPtr simultaneously.

WeakPtrFactory::createWeakPtr reads/writes 'm_ref' member variable without locking mutex.
https://trac.webkit.org/browser/webkit/trunk/Source/WTF/wtf/WeakPtr.h?rev=242387#L109

> WeakPtr<T> createWeakPtr(T& ptr) const
> {
>     if (!m_ref)
>         m_ref = WeakReference<T>::create(&ptr);
>     return { makeRef(*m_ref) };
> }

The simple solution is making WeakPtrFactory::m_ref always have a reference to a instance of WeakReference by calling createWeakPtr in WeakPtrFactory ctor.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190312/93f2338e/attachment.html>


More information about the webkit-unassigned mailing list