Bug 144183

Summary: Simplify DOM wrapper destruction, don't deref() in finalizers.
Product: WebKit Reporter: Andreas Kling <kling>
Component: WebCore JavaScriptAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch
darin: review+
Patch for landing none

Description Andreas Kling 2015-04-24 21:13:05 PDT
Finalizers are not guaranteed to run for a Weak if its WeakImpl has been replaced by another (through use of Weak::operator=(Weak&&)) before the GC's incremental sweeper has swept the containing WeakBlock.

Let's settle on a single way of invoking deref() on the DOM object.
Comment 1 Andreas Kling 2015-04-24 21:13:35 PDT
Created attachment 251609 [details]
Proposed patch
Comment 2 Darin Adler 2015-04-26 11:52:39 PDT
Comment on attachment 251609 [details]
Proposed patch

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

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1089
> +        push(@headerContent, "    void releaseImpl() { m_impl->deref(); m_impl = nullptr; }\n\n");

Could consider the suggestion Oliver Hunt made for the smart pointer classes:

    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }

That would mean that m_impl would be null if something happened to run in the destructor and turn around and see this object.
Comment 3 Andreas Kling 2015-04-28 16:55:57 PDT
Created attachment 251899 [details]
Patch for landing

With std::exchange like darin suggested.
Comment 4 Andreas Kling 2015-04-28 17:29:21 PDT
Comment on attachment 251899 [details]
Patch for landing

Holding cq+ while I check on a potential issue locally.
Comment 5 Andreas Kling 2015-04-28 18:25:45 PDT
Comment on attachment 251899 [details]
Patch for landing

Local issue was something else entirely. Resuming commit queue.
Comment 6 WebKit Commit Bot 2015-04-28 19:13:47 PDT
Comment on attachment 251899 [details]
Patch for landing

Clearing flags on attachment: 251899

Committed r183523: <http://trac.webkit.org/changeset/183523>
Comment 7 WebKit Commit Bot 2015-04-28 19:13:51 PDT
All reviewed patches have been landed.  Closing bug.