<?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>159331</bug_id>
          
          <creation_ts>2016-06-30 23:14:01 -0700</creation_ts>
          <short_desc>Deadlock inside -[WebCoreNSURLSession dealloc]</short_desc>
          <delta_ts>2016-07-01 10:24:16 -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>New Bugs</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="Jer Noble">jer.noble</reporter>
          <assigned_to name="Jer Noble">jer.noble</assigned_to>
          <cc>benjamin</cc>
    
    <cc>cdumez</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>ggaren</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1206996</commentid>
    <comment_count>0</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2016-06-30 23:14:01 -0700</bug_when>
    <thetext>SPIN inside -[WebCoreNSURLSession dealloc]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1206999</commentid>
    <comment_count>1</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2016-06-30 23:21:51 -0700</bug_when>
    <thetext>&lt;rdar://problem/27122716&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1207000</commentid>
    <comment_count>2</comment_count>
      <attachid>282513</attachid>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2016-06-30 23:25:41 -0700</bug_when>
    <thetext>Created attachment 282513
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1207011</commentid>
    <comment_count>3</comment_count>
      <attachid>282513</attachid>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-07-01 00:20:20 -0700</bug_when>
    <thetext>Comment on attachment 282513
Patch

Alternatively, you could just move the declaration of function inside the while loop scope (but not in the lock scope).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1207125</commentid>
    <comment_count>4</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2016-07-01 08:38:03 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; Comment on attachment 282513 [details]
&gt; Patch
&gt; 
&gt; Alternatively, you could just move the declaration of function inside the
&gt; while loop scope (but not in the lock scope).


I considered that, but thought this way would be slightly less expensive (no call to the constructor and destructor), as well as is more explicit about what&apos;s going on.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1207127</commentid>
    <comment_count>5</comment_count>
      <attachid>282513</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-07-01 08:41:05 -0700</bug_when>
    <thetext>Comment on attachment 282513
Patch

Clearing flags on attachment: 282513

Committed r202736: &lt;http://trac.webkit.org/changeset/202736&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1207128</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-07-01 08:41:10 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1207143</commentid>
    <comment_count>7</comment_count>
      <attachid>282513</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2016-07-01 09:30:18 -0700</bug_when>
    <thetext>Comment on attachment 282513
Patch

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

&gt; Source/WTF/wtf/MainThread.cpp:137
&gt; +        // Clearing the function can have side effects, so do so outside of the lock above.
&gt; +        function = nullptr;

Can we just move the declaration of function inside the loop? That&apos;s the C++ way to specify the semantics you want: Don&apos;t allow this value to outlive this loop body.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1207152</commentid>
    <comment_count>8</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2016-07-01 09:34:54 -0700</bug_when>
    <thetext>&gt; &gt; Alternatively, you could just move the declaration of function inside the
&gt; &gt; while loop scope (but not in the lock scope).
&gt; 
&gt; 
&gt; I considered that, but thought this way would be slightly less expensive (no
&gt; call to the constructor and destructor), as well as is more explicit about
&gt; what&apos;s going on.

There&apos;s no performance concern here. The empty constructor just assigns nullptr, which is exactly what you&apos;ve done manually. Actually, there&apos;s a slight performance win, since it&apos;s much easier for the compiler to notice that nullptr is never observed, and eliminate the store entirely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1207188</commentid>
    <comment_count>9</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2016-07-01 10:24:16 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; &gt; &gt; Alternatively, you could just move the declaration of function inside the
&gt; &gt; &gt; while loop scope (but not in the lock scope).
&gt; &gt; 
&gt; &gt; 
&gt; &gt; I considered that, but thought this way would be slightly less expensive (no
&gt; &gt; call to the constructor and destructor), as well as is more explicit about
&gt; &gt; what&apos;s going on.
&gt; 
&gt; There&apos;s no performance concern here. The empty constructor just assigns
&gt; nullptr, which is exactly what you&apos;ve done manually. Actually, there&apos;s a
&gt; slight performance win, since it&apos;s much easier for the compiler to notice
&gt; that nullptr is never observed, and eliminate the store entirely.

Okay, sure.  I&apos;ll post a follow up.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>282513</attachid>
            <date>2016-06-30 23:25:41 -0700</date>
            <delta_ts>2016-07-01 08:41:05 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-159331-20160630232519.patch</filename>
            <type>text/plain</type>
            <size>2132</size>
            <attacher name="Jer Noble">jer.noble</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjAyNzE5CmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IDZiZDM0M2Y0OTg0MTVlMzIxZTY1ODQ5
ZGE1MDI2ZDJiNGRiYzRiN2UuLjFiM2VmYmRjMzJkMWRiMTYyODA1ODcxMWQ4NzRlYTgwNjRiYmFh
ODcgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XVEYvQ2hh
bmdlTG9nCkBAIC0xLDMgKzEsMjUgQEAKKzIwMTYtMDYtMzAgIEplciBOb2JsZSAgPGplci5ub2Js
ZUBhcHBsZS5jb20+CisKKyAgICAgICAgRGVhZGxvY2sgaW5zaWRlIC1bV2ViQ29yZU5TVVJMU2Vz
c2lvbiBkZWFsbG9jXQorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5j
Z2k/aWQ9MTU5MzMxCisgICAgICAgIDxyZGFyOi8vcHJvYmxlbS8yNzEyMjcxNj4KKworICAgICAg
ICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBBIEZ1bmN0aW9uPD4gb2Jq
ZWN0IGNhbiB3cmFwIGFueSBjYWxsYWJsZSB0eXBlLCBpbmNsdWRpbmcgYSBDKysgbGFtYmRhLgor
CisgICAgICAgIGRpc3BhdGNoRnVuY3Rpb25zRnJvbU1haW5UaHJlYWQoKSBob2xkcyBhIGxvY2sg
d2hpbGUgaXRlcmF0aW5nIG92ZXIgdGhlIGZ1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