Bug 214835 - Update release*() functions on ExceptionOr() to always release the member
Summary: Update release*() functions on ExceptionOr() to always release the member
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-07-27 10:54 PDT by Chris Dumez
Modified: 2020-07-27 17:06 PDT (History)
8 users (show)

See Also:


Attachments
Patch (5.30 KB, patch)
2020-07-27 12:22 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (5.21 KB, patch)
2020-07-27 13:07 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (19.74 KB, patch)
2020-07-27 14:54 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-07-27 10:54:23 PDT
Update release*() functions on ExceptionOr() to always release the member, instead of simply doing a cast and leaving it up to the call site.
Comment 1 Darin Adler 2020-07-27 11:01:55 PDT
In addition to this good change, I still think we might *also* want to add an assertion to make sure we never double-release.
Comment 2 Chris Dumez 2020-07-27 12:13:02 PDT
(In reply to Darin Adler from comment #1)
> In addition to this good change, I still think we might *also* want to add
> an assertion to make sure we never double-release.

Working on it. I ran the tests and it actually found a bug :S
Comment 3 Chris Dumez 2020-07-27 12:22:47 PDT
Created attachment 405302 [details]
Patch
Comment 4 Darin Adler 2020-07-27 13:00:57 PDT
Comment on attachment 405302 [details]
Patch

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

> Source/WebCore/dom/ExceptionOr.h:140
> +    ASSERT(!m_wasReleased);
> +#if ASSERT_ENABLED
> +    m_wasReleased = true;
> +#endif

I have a horrible/great idea:

    ASSERT(!std::exchnage(m_wasReleased, true));
Comment 5 Chris Dumez 2020-07-27 13:06:22 PDT
(In reply to Darin Adler from comment #4)
> Comment on attachment 405302 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=405302&action=review
> 
> > Source/WebCore/dom/ExceptionOr.h:140
> > +    ASSERT(!m_wasReleased);
> > +#if ASSERT_ENABLED
> > +    m_wasReleased = true;
> > +#endif
> 
> I have a horrible/great idea:
> 
>     ASSERT(!std::exchnage(m_wasReleased, true));

Not super readable but this is way more concise and avoid the #if. I'll do it.
Comment 6 Chris Dumez 2020-07-27 13:07:25 PDT
Created attachment 405305 [details]
Patch
Comment 7 Darin Adler 2020-07-27 13:07:41 PDT
(In reply to Chris Dumez from comment #5)
> Not super readable but this is way more concise and avoid the #if. I'll do
> it.

Glad you decided to use it. I guessed that you would see both the horrible side and the great side.
Comment 8 Chris Dumez 2020-07-27 14:08:38 PDT
Bots are not happy. Looks like this may have found another bug in IDB.
Comment 9 Chris Dumez 2020-07-27 14:21:52 PDT
(In reply to Chris Dumez from comment #8)
> Bots are not happy. Looks like this may have found another bug in IDB.

Or maybe not. I see the same IDB failures on another patch.. Tree is likely red.
Comment 10 Chris Dumez 2020-07-27 14:54:06 PDT
Created attachment 405313 [details]
Patch
Comment 11 EWS 2020-07-27 17:05:10 PDT
Committed r264958: <https://trac.webkit.org/changeset/264958>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 405313 [details].
Comment 12 Radar WebKit Bug Importer 2020-07-27 17:06:26 PDT
<rdar://problem/66189892>