<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>201249</bug_id>
          
          <creation_ts>2019-08-28 16:26:12 -0700</creation_ts>
          <short_desc>CompletionHandler default constructor does not initialize `m_wasConstructedOnMainThread`</short_desc>
          <delta_ts>2019-08-29 10:12:27 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Template Framework</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>achristensen</cc>
    
    <cc>benjamin</cc>
    
    <cc>cdumez</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>dbates</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>joepeck</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1565943</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-08-28 16:26:12 -0700</bug_when>
    <thetext>CompletionHandler default constructor does not initialize `m_wasConstructedOnMainThread`</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565946</commentid>
    <comment_count>1</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-08-28 16:28:43 -0700</bug_when>
    <thetext>Debug only member for assertions. I&apos;m seeing assertions!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565947</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-28 16:31:06 -0700</bug_when>
    <thetext>(In reply to Joseph Pecoraro from comment #1)
&gt; Debug only member for assertions. I&apos;m seeing assertions!

Oh, I guess if somebody default-constructs a CompletionHandler and then later on assigns a lambda to it, and then calls the completion handler on the wrong thread. You found cases like this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565950</commentid>
    <comment_count>3</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-08-28 16:39:56 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #2)
&gt; (In reply to Joseph Pecoraro from comment #1)
&gt; &gt; Debug only member for assertions. I&apos;m seeing assertions!
&gt; 
&gt; Oh, I guess if somebody default-constructs a CompletionHandler and then
&gt; later on assigns a lambda to it, and then calls the completion handler on
&gt; the wrong thread. You found cases like this?

I&apos;m adding code that is essentially like:

    CompletionHandler&lt;void&gt; handler;
    callOnMainThread([handler = WTFMove(handler)] mutable {
        handler();
    });

And it is asserting.

If I instead did:

    CompletionHandler&lt;void&gt; handler = []{};
    callOnMainThread([handler = WTFMove(handler)] mutable {
        handler();
    });

it is not asserting.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565952</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-28 16:41:09 -0700</bug_when>
    <thetext>(In reply to Joseph Pecoraro from comment #3)
&gt; (In reply to Chris Dumez from comment #2)
&gt; &gt; (In reply to Joseph Pecoraro from comment #1)
&gt; &gt; &gt; Debug only member for assertions. I&apos;m seeing assertions!
&gt; &gt; 
&gt; &gt; Oh, I guess if somebody default-constructs a CompletionHandler and then
&gt; &gt; later on assigns a lambda to it, and then calls the completion handler on
&gt; &gt; the wrong thread. You found cases like this?
&gt; 
&gt; I&apos;m adding code that is essentially like:
&gt; 
&gt;     CompletionHandler&lt;void&gt; handler;
&gt;     callOnMainThread([handler = WTFMove(handler)] mutable {
&gt;         handler();
&gt;     });
&gt; 
&gt; And it is asserting.
&gt; 
&gt; If I instead did:
&gt; 
&gt;     CompletionHandler&lt;void&gt; handler = []{};
&gt;     callOnMainThread([handler = WTFMove(handler)] mutable {
&gt;         handler();
&gt;     });
&gt; 
&gt; it is not asserting.

Yes, you&apos;re not allowed to call a default constructed Function or CompletionHandler, it is by design and has nothing to do with threading.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565953</commentid>
    <comment_count>5</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-08-28 16:46:26 -0700</bug_when>
    <thetext>&gt; Yes, you&apos;re not allowed to call a default constructed Function or
&gt; CompletionHandler, it is by design and has nothing to do with threading.

Okay, sounds good. I can check if the completion handler was initialized (operator bool) in these cases. Note that `CompletionHandlerCallingScope` does just that.

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565954</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-28 16:47:39 -0700</bug_when>
    <thetext>Why are we closing this. We should probably still fix the bug where m_wasConstructedOnMainThread is not initialized.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565955</commentid>
    <comment_count>7</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-28 16:47:57 -0700</bug_when>
    <thetext>Will fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565956</commentid>
    <comment_count>8</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-08-28 16:49:11 -0700</bug_when>
    <thetext>Fair enough, but if we fix this won&apos;t it just assert next that the function is not callable next. So some assertion will happen.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565957</commentid>
    <comment_count>9</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-28 16:50:30 -0700</bug_when>
    <thetext>(In reply to Joseph Pecoraro from comment #8)
&gt; Fair enough, but if we fix this won&apos;t it just assert next that the function
&gt; is not callable next. So some assertion will happen.

Right, but still seems wrong to have an uninitialized data member.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565958</commentid>
    <comment_count>10</comment_count>
      <attachid>377511</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-28 16:51:06 -0700</bug_when>
    <thetext>Created attachment 377511
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565960</commentid>
    <comment_count>11</comment_count>
      <attachid>377511</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-08-28 16:52:02 -0700</bug_when>
    <thetext>Comment on attachment 377511
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565961</commentid>
    <comment_count>12</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-08-28 16:52:32 -0700</bug_when>
    <thetext>&gt; Right, but still seems wrong to have an uninitialized data member.

Sounds good!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565963</commentid>
    <comment_count>13</comment_count>
      <attachid>377511</attachid>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2019-08-28 16:54:09 -0700</bug_when>
    <thetext>Comment on attachment 377511
Patch

Why not just put this in an initializer list and keep the =default?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1565964</commentid>
    <comment_count>14</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-28 16:56:53 -0700</bug_when>
    <thetext>(In reply to Alex Christensen from comment #13)
&gt; Comment on attachment 377511 [details]
&gt; Patch
&gt; 
&gt; Why not just put this in an initializer list and keep the =default?

Oh, I can try this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1566233</commentid>
    <comment_count>15</comment_count>
      <attachid>377587</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-29 08:24:06 -0700</bug_when>
    <thetext>Created attachment 377587
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1566279</commentid>
    <comment_count>16</comment_count>
      <attachid>377587</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-08-29 10:11:12 -0700</bug_when>
    <thetext>Comment on attachment 377587
Patch

Clearing flags on attachment: 377587

Committed r249280: &lt;https://trac.webkit.org/changeset/249280&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1566280</commentid>
    <comment_count>17</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-08-29 10:11:13 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1566281</commentid>
    <comment_count>18</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-08-29 10:12:27 -0700</bug_when>
    <thetext>&lt;rdar://problem/54841787&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>377511</attachid>
            <date>2019-08-28 16:51:06 -0700</date>
            <delta_ts>2019-08-29 08:24:05 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-201249-20190828165106.patch</filename>
            <type>text/plain</type>
            <size>1495</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjQ5MjI1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IGQ0YjhkZDEyZGM0NzZlODllY2MyYmJk
Nzc3OWU1OTFmMWZmYzg2MzcuLjkxMzNhZjQ4NjZmMTZkYWNlMzY3NzgzZjAxZWI1ZmIwYTRkM2Rj
NDkgMTAwNjQ0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25IYW5kbGVyLmgKKysrIGIvU291cmNlL1dURi93dGYvQ29tcGxldGlvbkhhbmRsZXIuaApAQCAt
MzcsNyArMzcsMTIgQEAgdGVtcGxhdGUgPHR5cGVuYW1lIE91dCwgdHlwZW5hbWUuLi4gSW4+CiBj
bGFzcyBDb21wbGV0aW9uSGFuZGxlcjxPdXQoSW4uLi4pPiB7CiAgICAgV1RGX01BS0VfRkFTVF9B
TExPQ0FURUQ7CiBwdWJsaWM6Ci0gICAgQ29tcGxldGlvbkhhbmRsZXIoKSA9IGRlZmF1bHQ7Cisg
ICAgQ29tcGxldGlvbkhhbmRsZXIoKQorI2lmICFBU1NFUlRfRElTQUJMRUQKKyAgICAgICAgOiBt
X3dhc0NvbnN0cnVjdGVkT25NYWluVGhyZWFkKGlzTWFpblRocmVhZCgpKQorI2VuZGlmCisgICAg
eworICAgIH0KIAogICAgIHRlbXBsYXRlPHR5cGVuYW1lIENhbGxhYmxlVHlwZSwgY2xhc3MgPSB0
eXBlbmFtZSBzdGQ6OmVuYWJsZV9pZjxzdGQ6OmlzX3J2YWx1ZV9yZWZlcmVuY2U8Q2FsbGFibGVU
eXBlJiY+Ojp2YWx1ZT46OnR5cGU+CiAgICAgQ29tcGxldGlvbkhhbmRsZXIoQ2FsbGFibGVUeXBl
JiYgY2FsbGFibGUpCg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>377587</attachid>
            <date>2019-08-29 08:24:06 -0700</date>
            <delta_ts>2019-08-29 10:11:12 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-201249-20190829082405.patch</filename>
            <type>text/plain</type>
            <size>1595</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjQ5MjI1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IGQ0Yjh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