<?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>174714</bug_id>
          
          <creation_ts>2017-07-21 09:06:11 -0700</creation_ts>
          <short_desc>Drop WTF::initializeDate, if we can stop using -fno-threadsafe-statics</short_desc>
          <delta_ts>2017-07-23 09:47:00 -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>REOPENED</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=174752</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>174748</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yusuke Suzuki">ysuzuki</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>ap</cc>
    
    <cc>benjamin</cc>
    
    <cc>buildbot</cc>
    
    <cc>cdumez</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>dbates</cc>
    
    <cc>dewei_zhu</cc>
    
    <cc>fujii</cc>
    
    <cc>mark.lam</cc>
    
    <cc>rniwa</cc>
    
    <cc>saam</cc>
    
    <cc>sam</cc>
    
    <cc>slewis</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1330976</commentid>
    <comment_count>0</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-07-21 09:06:11 -0700</bug_when>
    <thetext>[WTF] Drop initializeDate</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1330977</commentid>
    <comment_count>1</comment_count>
      <attachid>316092</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-07-21 09:07:34 -0700</bug_when>
    <thetext>Created attachment 316092
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1330990</commentid>
    <comment_count>2</comment_count>
      <attachid>316092</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-07-21 09:59:50 -0700</bug_when>
    <thetext>Comment on attachment 316092
Patch

Clearing flags on attachment: 316092

Committed r219732: &lt;http://trac.webkit.org/changeset/219732&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1330991</commentid>
    <comment_count>3</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-07-21 09:59:51 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331018</commentid>
    <comment_count>4</comment_count>
      <attachid>316092</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-07-21 10:49:42 -0700</bug_when>
    <thetext>Comment on attachment 316092
Patch

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

&gt; Source/WTF/ChangeLog:8
&gt; +        minYear static variable will be initialized in an exclusive manner, which is ensured by C++ &quot;static&quot; semantics.

Is that true? I thought we were compiling with no-threadsafe-statics.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331019</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2017-07-21 10:51:25 -0700</bug_when>
    <thetext>(In reply to Alexey Proskuryakov from comment #4)
&gt; Comment on attachment 316092 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=316092&amp;action=review
&gt; 
&gt; &gt; Source/WTF/ChangeLog:8
&gt; &gt; +        minYear static variable will be initialized in an exclusive manner, which is ensured by C++ &quot;static&quot; semantics.
&gt; 
&gt; Is that true? I thought we were compiling with no-threadsafe-statics.

I think our NeverDestroyed implementation relies on threadsafe-statics.  Otherwise, we&apos;ll have issues, no?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331021</commentid>
    <comment_count>6</comment_count>
      <attachid>316092</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-07-21 10:54:16 -0700</bug_when>
    <thetext>Comment on attachment 316092
Patch

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

&gt;&gt;&gt; Source/WTF/ChangeLog:8
&gt;&gt;&gt; +        minYear static variable will be initialized in an exclusive manner, which is ensured by C++ &quot;static&quot; semantics.
&gt;&gt; 
&gt;&gt; Is that true? I thought we were compiling with no-threadsafe-statics.
&gt; 
&gt; I think our NeverDestroyed implementation relies on threadsafe-statics.  Otherwise, we&apos;ll have issues, no?

Right, if we compiled WebKit with no-threadsafe-statics, we should already encounter issues with NeverDestroyed.
I remember that I grepped this a bit while ago, and I can&apos;t find any no-threadsafe-statics in WebKit build settings. Only libwebrtc uses it. But WebKit itself does not.
I&apos;ve grepped again now and I can&apos;t find it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331083</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-07-21 13:19:14 -0700</bug_when>
    <thetext>We do compile with no-threadsafe-statics.

We only use initialization NeverDestroyed when thread safety is not needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331084</commentid>
    <comment_count>8</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-07-21 13:19:42 -0700</bug_when>
    <thetext>Many of the uses of LazyNeverDestroyed that use std::call_once are for thread safety.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331085</commentid>
    <comment_count>9</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-07-21 13:20:20 -0700</bug_when>
    <thetext>Maybe I am wrong. If we really stopped using -fno-threadsafe-statics, then I can do another round of cleanup and get rid of almost all uses of LazyNeverDestroyed!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331179</commentid>
    <comment_count>10</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-07-21 16:17:33 -0700</bug_when>
    <thetext>WebKit is built with -fno-threadsafe-statics. Perhaps there is some configuration that enables that, but all that I checked do not.

See e.g. https://build.webkit.org/builders/Apple%20Sierra%20Release%20%28Build%29/builds/3721/steps/compile-webkit/logs/stdio</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331184</commentid>
    <comment_count>11</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-07-21 16:22:17 -0700</bug_when>
    <thetext>Checking wtf/DateMath.cpp specifically, it is also compiled with -fno-threadsafe-statics.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331283</commentid>
    <comment_count>12</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-07-21 21:47:09 -0700</bug_when>
    <thetext>So did we create a thread safety problem or not? Can equivalentYearForDST be called from multiple threads?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331284</commentid>
    <comment_count>13</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-07-21 21:47:40 -0700</bug_when>
    <thetext>I think we did, and I think this patch probably needs to be rolled out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331290</commentid>
    <comment_count>14</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-07-21 22:09:54 -0700</bug_when>
    <thetext>(In reply to Darin Adler from comment #7)
&gt; We do compile with no-threadsafe-statics.
&gt; 
&gt; We only use initialization NeverDestroyed when thread safety is not needed.

I think we have a problem. I remember that Mark changed NeverDestroyed&lt;String&gt;&apos;s ASCIILiteral parameter to StaticStringImpl because this is not safe to access NeverDestroyed&lt;String&gt;.
It means that some of NeverDestroyed&lt;String&gt; can be accessed from multiple threads. If so, without threadsafe statics, it is dangerous.
I think we will see
1. constructor is called twice, it may break structure during the other thread uses it.
2. we may return half-baked structure if the other thread is constructing it right now.

(In reply to Alexey Proskuryakov from comment #10)
&gt; WebKit is built with -fno-threadsafe-statics. Perhaps there is some
&gt; configuration that enables that, but all that I checked do not.
&gt; 
&gt; See e.g.
&gt; https://build.webkit.org/builders/Apple%20Sierra%20Release%20%28Build%29/
&gt; builds/3721/steps/compile-webkit/logs/stdio

Wow, that&apos;s a problem! I didn&apos;t know that this is enabled since any xcodeproje does not specify it.
We should adopt this option in CMake build files as well to clarify our build configuration. Filed. https://bugs.webkit.org/show_bug.cgi?id=174747

(In reply to Darin Adler from comment #13)
&gt; I think we did, and I think this patch probably needs to be rolled out.

Yes, we should roll out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331292</commentid>
    <comment_count>15</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-07-21 22:11:35 -0700</bug_when>
    <thetext>Re-opened since this is blocked by bug 174748</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331299</commentid>
    <comment_count>16</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-07-21 22:35:30 -0700</bug_when>
    <thetext>For example, I think JSC/runtime/JSGlobalObjectFunctions.cpp&apos;s Bitmaps are racy if threadsafe statics is not ensured.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1331362</commentid>
    <comment_count>17</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-07-22 10:35:28 -0700</bug_when>
    <thetext>To make our programming easier we can start compiling all of WebKit with thread-safe statics if we can do performance tests and prove that it does not come at an unacceptable performance cost. At the time we originally turned that flag on it was critical for performance.

Until then if we accidentally write code with thread safety problems then we should rewrite to avoid those problems.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>316092</attachid>
            <date>2017-07-21 09:07:34 -0700</date>
            <delta_ts>2017-07-21 09:59:50 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-174714-20170722010733.patch</filename>
            <type>text/plain</type>
            <size>2704</size>
            <attacher name="Yusuke Suzuki">ysuzuki</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjE5NzI3CmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IDU3ODZhNjg2NGE3NTc4MWY2OTQzMjky
YTEyOWQwNDc4MjE2MDVlZjQuLjY5NGVkODJmN2ExNjYzYTc2YTFhZmM5NGYzNjE3ZDk1Y2VlOTll
YzIgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XVEYvQ2hh
bmdlTG9nCkBAIC0xLDUgKzEsMjEgQEAKIDIwMTctMDctMjEgIFl1c3VrZSBTdXp1a2kgIDx1dGF0
YW5lLnRlYUBnbWFpbC5jb20+CiAKKyAgICAgICAgW1dURl0gRHJvcCBpbml0aWFsaXplRGF0ZQor
ICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MTc0NzE0CisK
KyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgbWluWWVhciBz
dGF0aWMgdmFyaWFibGUgd2lsbCBiZSBpbml0aWFsaXplZCBpbiBhbiBleGNsdXNpdmUgbWFubmVy
LCB3aGljaCBpcyBlbnN1cmVkIGJ5IEMrKyAic3RhdGljIiBzZW1hbnRpY3MuCisgICAgICAgIFRo
dXMsIHdlIGRvIG5vdCBuZWVkIHRvIGNhbGwgaW5pdGlhbGl6ZURhdGUoKSBleHBsaWNpdGx5Lgor
CisgICAgICAgICogd3RmL0RhdGVNYXRoLmNwcDoKKy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