Bug 197641 - Add a release assertion that Functions can only be constructed from non-null CompletionHandlers
Summary: Add a release assertion that Functions can only be constructed from non-null ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-05-06 17:58 PDT by Alex Christensen
Modified: 2019-05-07 12:55 PDT (History)
6 users (show)

See Also:


Attachments
Patch (6.13 KB, patch)
2019-05-06 18:02 PDT, Alex Christensen
cdumez: review+
Details | Formatted Diff | Diff
Archive of layout-test-results from ews210 for win-future (13.60 MB, application/zip)
2019-05-07 07:09 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2019-05-06 17:58:42 PDT
Add a release assertion that Functions can only be constructed from non-null CompletionHandlers
Comment 1 Alex Christensen 2019-05-06 18:02:52 PDT
Created attachment 369213 [details]
Patch
Comment 2 Build Bot 2019-05-07 07:09:48 PDT
Comment on attachment 369213 [details]
Patch

Attachment 369213 [details] did not pass win-ews (win):
Output: https://webkit-queues.webkit.org/results/12122984

New failing tests:
security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star.html
Comment 3 Build Bot 2019-05-07 07:09:50 PDT
Created attachment 369280 [details]
Archive of layout-test-results from ews210 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews210  Port: win-future  Platform: CYGWIN_NT-10.0-17763-3.0.5-338.x86_64-x86_64-64bit
Comment 4 Chris Dumez 2019-05-07 08:44:51 PDT
Comment on attachment 369213 [details]
Patch

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

> Source/WTF/wtf/Function.h:33
> +namespace Detail {

Why is this better than a private class in the Function scope? I preferred the old way as it was hiding the implementation detail. Now it's public and anyone could use it directly in theory.
Comment 5 Alex Christensen 2019-05-07 11:48:15 PDT
Private classes inside template classes seem to be unspecializable.  I only get these:
error: cannot specialize a member of an unspecialized template
This is what Detail namespaces are for.
Comment 6 Chris Dumez 2019-05-07 11:56:37 PDT
Comment on attachment 369213 [details]
Patch

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

> Source/WTF/wtf/CompletionHandler.h:68
> +template<typename Out, typename... In>

Should we add a FIXME to indicate this is temporary? I don't this this would stay a RELEASE_ASSERT() forever and it seems like a lot of extra code for a debug ASSERT().
Comment 7 Alex Christensen 2019-05-07 12:15:17 PDT
I'm not convinced this is temporary.  We should always be unable to make a non-null Function that when called will always dereference null.
Also, we could use this same technique to make a CallableWrapperStorage class that is usually a unique_ptr but is just a CompletionHandler for the Function-wrapping-CompletionHandler case.  We should also make Function more const correct by making operator() const if the lambda is not mutable and non-const for mutable lambdas.  There's work to be done here.
Comment 8 Alex Christensen 2019-05-07 12:54:13 PDT
http://trac.webkit.org/r245024
Comment 9 Radar WebKit Bug Importer 2019-05-07 12:55:29 PDT
<rdar://problem/50551693>