Bug 214835

Summary: Update release*() functions on ExceptionOr() to always release the member
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebCore Misc.Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: alecflett, beidson, darin, esprehn+autocc, ews-watchlist, jsbell, kangil.han, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=214746
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

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>