<?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>173720</bug_id>
          
          <creation_ts>2017-06-22 09:38:52 -0700</creation_ts>
          <short_desc>initializeThreading() [first] causes WTFCrash due to maxSingleAllocationSize not being initialized</short_desc>
          <delta_ts>2017-06-25 14:41:56 -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>JavaScriptCore</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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vladimir Vukicevic">vladimir</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>benjamin</cc>
    
    <cc>buildbot</cc>
    
    <cc>cdumez</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>dbates</cc>
    
    <cc>mark.lam</cc>
    
    <cc>sam</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1321928</commentid>
    <comment_count>0</comment_count>
    <who name="Vladimir Vukicevic">vladimir</who>
    <bug_when>2017-06-22 09:38:52 -0700</bug_when>
    <thetext>This is probably an edge case, but -- in a JSC static build that gets linked into another DLL, and that DLL does some dumb stuff from static constructors, such as JSClassCreate, I get this crash because maxSingleAllocationSize is still 0 (it&apos;s set by Options::initialize() which hasn&apos;t been called yet by initializeThreading()) -- lambdas and other junk omitted from stack:

WTFCrash()
WTF::fastMalloc(unsigned __int64 n)
WTF::Lock::operator new(unsigned __int64 size)
std::make_unique&lt;WTF::Lock&gt;()
WTF::threadMap()
WTF::ThreadHolder::initializeOnce()
WTF::initializeThreading()
JSC::initializeThreading::__l2::&lt;lambda&gt;()
JSC::initializeThreading()
JSClassCreate(const JSClassDefinition * definition)
...

I don&apos;t know if this is valid (to do stuff like JSClassCreate from constructors without doing explicit engine initialization), but it worked on older versions of jscore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1321931</commentid>
    <comment_count>1</comment_count>
    <who name="Vladimir Vukicevic">vladimir</who>
    <bug_when>2017-06-22 09:40:43 -0700</bug_when>
    <thetext>Actually, now that I look closer.. I don&apos;t get how it&apos;s not initialized to size_t::max(), but is 0, other than static initializer order goop since it&apos;s initialized using &apos;std::numeric_limits&lt;size_t&gt;::max();&apos; ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1321937</commentid>
    <comment_count>2</comment_count>
    <who name="Vladimir Vukicevic">vladimir</who>
    <bug_when>2017-06-22 09:49:38 -0700</bug_when>
    <thetext>Yep, changing the static initializer to a simple &quot;= SIZE_MAX;&quot; fixes this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1321939</commentid>
    <comment_count>3</comment_count>
    <who name="Vladimir Vukicevic">vladimir</who>
    <bug_when>2017-06-22 09:59:08 -0700</bug_when>
    <thetext>VS 2017 (cl 19.10.25019). max() is constexpr, so, I dunno why!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322224</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-06-23 01:49:39 -0700</bug_when>
    <thetext>(In reply to Vladimir Vukicevic from comment #3)
&gt; VS 2017 (cl 19.10.25019). max() is constexpr, so, I dunno why!

Hmmmmm, yeah, that is strange. In the meantime, we just use SIZE_MAX.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322225</commentid>
    <comment_count>5</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-06-23 01:51:02 -0700</bug_when>
    <thetext>(In reply to Vladimir Vukicevic from comment #0)
&gt; This is probably an edge case, but -- in a JSC static build that gets linked
&gt; into another DLL, and that DLL does some dumb stuff from static
&gt; constructors, such as JSClassCreate, I get this crash because
&gt; maxSingleAllocationSize is still 0 (it&apos;s set by Options::initialize() which
&gt; hasn&apos;t been called yet by initializeThreading()) -- lambdas and other junk
&gt; omitted from stack:
&gt; 
&gt; WTFCrash()
&gt; WTF::fastMalloc(unsigned __int64 n)
&gt; WTF::Lock::operator new(unsigned __int64 size)
&gt; std::make_unique&lt;WTF::Lock&gt;()
&gt; WTF::threadMap()
&gt; WTF::ThreadHolder::initializeOnce()
&gt; WTF::initializeThreading()
&gt; JSC::initializeThreading::__l2::&lt;lambda&gt;()
&gt; JSC::initializeThreading()
&gt; JSClassCreate(const JSClassDefinition * definition)
&gt; ...
&gt; 
&gt; I don&apos;t know if this is valid (to do stuff like JSClassCreate from
&gt; constructors without doing explicit engine initialization), but it worked on
&gt; older versions of jscore.

Basically, we do not allow static constructors in WebKit.
If we use static constructors, mac build with clang will fail due to the option restricting static constructors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322228</commentid>
    <comment_count>6</comment_count>
      <attachid>313700</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-06-23 01:55:39 -0700</bug_when>
    <thetext>Created attachment 313700
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322725</commentid>
    <comment_count>7</comment_count>
      <attachid>313700</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2017-06-25 14:11:53 -0700</bug_when>
    <thetext>Comment on attachment 313700
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322727</commentid>
    <comment_count>8</comment_count>
      <attachid>313700</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-06-25 14:14:29 -0700</bug_when>
    <thetext>Comment on attachment 313700
Patch

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322731</commentid>
    <comment_count>9</comment_count>
      <attachid>313700</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-06-25 14:41:54 -0700</bug_when>
    <thetext>Comment on attachment 313700
Patch

Clearing flags on attachment: 313700

Committed r218800: &lt;http://trac.webkit.org/changeset/218800&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322732</commentid>
    <comment_count>10</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-06-25 14:41:56 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>313700</attachid>
            <date>2017-06-23 01:55:39 -0700</date>
            <delta_ts>2017-06-25 14:41:54 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-173720-20170623175538.patch</filename>
            <type>text/plain</type>
            <size>1689</size>
            <attacher name="Yusuke Suzuki">ysuzuki</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjE4NzM4CmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IDMxZjdkNThhOTdlZTg3MTZlYTUzYWIz
NjRmMGQzYjAxN2IzMThjMzAuLjRjNDQxNzNkODE3ODBkYTMxMTg1NTJiZDg4N2ZkM2YzOGNlZDNm
MmIgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XVEYvQ2hh
bmdlTG9nCkBAIC0xLDMgKzEsMTkgQEAKKzIwMTctMDYtMjMgIFl1c3VrZSBTd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