[Webkit-unassigned] [Bug 186269] New: Make it possible to track unbalanced ref()/deref()

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 4 08:21:50 PDT 2018


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

            Bug ID: 186269
           Summary: Make it possible to track unbalanced ref()/deref()
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Tools / Tests
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: simon.fraser at apple.com
                CC: lforschler at apple.com

I have some hacks to Ref/RefPtr to make it possible to track unbalanced ref()/deref().

The idea is this:
* typedef unsigned WTF::RefToken
* change the signature of void ref() to WTF::RefToken ref();
* change the signature of void deref() to void defref(WTF::RefToken);
* Add RefTracker, which creates new RefToken, and records a stack trace when it does so. RefTracker stores a HashMap<RefToken, std::unique_ptr<StackShot>>.
* RefTracker removes its hash map entry when deref() is called with a given token.
* For a class whose refs you want to track (e.g. Node), store a RefTracker.
* The ref implementation becomes:

WTF::RefToken Node::ref()
{
  ++m_refCount;
  return m_refTracker.trackRef()
}

void Node::deref(WTF::RefToken token)
{
  m_refTracker.trackDeref(token);
  --m_refCount;
}

Then RefPtr<> and Ref<> are changed to store WTF::RefTokens, allowing them to pass tokens between matched ref() and deref().

Then, at some point, you ask the RefTracker to dump the StackShots that remain, which will be the ones for which no token was tracked, or which are unbalanced ref() and deref().

Of course this breaks down with code that does manual ref() and deref(), though callers can do their own RefToken tracking to help pair things up.

-- 
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/20180604/7f851236/attachment.html>


More information about the webkit-unassigned mailing list