<?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>161308</bug_id>
          
          <creation_ts>2016-08-29 03:48:19 -0700</creation_ts>
          <short_desc>REGRESSION (r205107): ASSERTION FAILED: !(reinterpret_cast&lt;char*&gt;(this)[i])</short_desc>
          <delta_ts>2016-08-31 11:22:34 -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>
          <dependson>161427</dependson>
          <blocked>161268</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Carlos Alberto Lopez Perez">clopez</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ossy</cc>
    
    <cc>saam</cc>
    
    <cc>ysuzuki</cc>
    
    <cc>zan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1224155</commentid>
    <comment_count>0</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2016-08-29 03:48:19 -0700</bug_when>
    <thetext>Revision r205107 &lt;http://trac.webkit.org/r205107&gt; has caused lot of assertions on the Debug build of GTK+: https://build.webkit.org/builders/GTK%20Linux%2064-bit%20Debug%20%28Tests%29/builds/10835

Backtrace:

ASSERTION FAILED: !(reinterpret_cast&lt;char*&gt;(this)[i])
../../Source/JavaScriptCore/dfg/DFGAbstractValue.h(66) : JSC::DFG::AbstractValue::AbstractValue()
1   0x7f5e53a30411 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(WTFCrash+0x1e) [0x7f5e53a30411]
2   0x7f5e530e5262 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::AbstractValue::AbstractValue()+0x96) [0x7f5e530e5262]
3   0x7f5e53115412 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::AbstractValue::fullTop()+0x19) [0x7f5e53115412]
4   0x7f5e53114b74 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::BasicBlock::BasicBlock(unsigned int, unsigned int, unsigned int, float)+0x12e) [0x7f5e53114b74]
5   0x7f5e5312f9e0 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::ByteCodeParser::parseCodeBlock()+0x60e) [0x7f5e5312f9e0]
6   0x7f5e5312ffb6 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::ByteCodeParser::parse()+0x1c8) [0x7f5e5312ffb6]
7   0x7f5e531302aa /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::parse(JSC::DFG::Graph&amp;)+0x3b) [0x7f5e531302aa]
8   0x7f5e533155c4 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::Plan::compileInThreadImpl(JSC::DFG::LongLivedState&amp;)+0xe2) [0x7f5e533155c4]
9   0x7f5e53314fcf /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::Plan::compileInThread(JSC::DFG::LongLivedState&amp;, JSC::DFG::ThreadData*)+0x173) [0x7f5e53314fcf]
10  0x7f5e53423754 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::Worklist::runThread(JSC::DFG::ThreadData*)+0x316) [0x7f5e53423754]
11  0x7f5e53423a7a /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(JSC::DFG::Worklist::threadFunction(void*)+0x2a) [0x7f5e53423a7a]
12  0x7f5e53a4d6be /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(+0x228c6be) [0x7f5e53a4d6be]
13  0x7f5e53a4d874 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(+0x228c874) [0x7f5e53a4d874]
14  0x7f5e5a04c7ce /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(std::function&lt;void ()&gt;::operator()() const+0x32) [0x7f5e5a04c7ce]
15  0x7f5e53a4d5a0 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(+0x228c5a0) [0x7f5e53a4d5a0]
16  0x7f5e53a887e1 /home/slave/webkitgtk/gtk-linux-64-debug/build/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(+0x22c77e1) [0x7f5e53a887e1]
17  0x7f5e4f88f0a4 /lib/x86_64-linux-gnu/libpthread.so.0(+0x80a4) [0x7f5e4f88f0a4]
18  0x7f5e4afc587d /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f5e4afc587d]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224158</commentid>
    <comment_count>1</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-08-29 03:58:47 -0700</bug_when>
    <thetext>All layout tests are crashing for the same assert in the Debug bot.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224163</commentid>
    <comment_count>2</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-08-29 06:08:48 -0700</bug_when>
    <thetext>I don&apos;t think this is GTK specific, Carlos confirmed he could reproduce the assert with jsconly but only when building with GCC, not with clang.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224269</commentid>
    <comment_count>3</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-08-29 12:03:40 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; I don&apos;t think this is GTK specific, Carlos confirmed he could reproduce the
&gt; assert with jsconly but only when building with GCC, not with clang.

Interesting. Any idea on why this may be?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224270</commentid>
    <comment_count>4</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-08-29 12:07:09 -0700</bug_when>
    <thetext>I wonder if GCC is emitting a 32-bit store instead of a 64-bit store?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224335</commentid>
    <comment_count>5</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-08-29 14:03:44 -0700</bug_when>
    <thetext>Maybe the bug is not changing the &quot;1u&quot; to &quot;1ull&quot; inside SpeculatedType.h?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224425</commentid>
    <comment_count>6</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2016-08-29 16:32:02 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; Maybe the bug is not changing the &quot;1u&quot; to &quot;1ull&quot; inside SpeculatedType.h?

I just tested to replace all occurrences of &quot;1u&quot; with &quot;1ull&quot; in SpeculatedType.h, and did a debug build of JSCOnly with GCC 4.9.

It is still crashing with the same assert.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224482</commentid>
    <comment_count>7</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-08-29 18:40:50 -0700</bug_when>
    <thetext>Ok.
Third guess, there is now 4 bytes of padding after the ArrayModes m_arrayModes
field, maybe those aren&apos;t getting zeroed out? And for some reason, clang zeroes
them out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224520</commentid>
    <comment_count>8</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2016-08-30 00:50:48 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; Ok.
&gt; Third guess, there is now 4 bytes of padding after the ArrayModes
&gt; m_arrayModes
&gt; field, maybe those aren&apos;t getting zeroed out? And for some reason, clang
&gt; zeroes
&gt; them out.

That&apos;s the reason.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224526</commentid>
    <comment_count>9</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-08-30 01:50:55 -0700</bug_when>
    <thetext>// The WTF Traits for AbstractValue allow the initialization of values with bzero().
// We verify the correctness of this assumption here.

So, that&apos;s assuming that AbstractValue is always created as a Vector or Hash value and then initialized by them with memset. But AbstractValue::heapTop(), AbstractValue::bytecodeTop() and AbstractValue::fullTop() are creating a stack allocated AbstractValue that is not zero initialized.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224840</commentid>
    <comment_count>10</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2016-08-30 19:51:20 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; Ok.
&gt; Third guess, there is now 4 bytes of padding after the ArrayModes
&gt; m_arrayModes
&gt; field, maybe those aren&apos;t getting zeroed out? And for some reason, clang
&gt; zeroes
&gt; them out.

It seems that the standard only guarantees that the padding in structures is zero-initialized on some very specific cases [1]. In the rest of cases it is undefined behaviour. And this seems to be one of this cases. That explains why clang is zero-initializing the padding of the structure, but GCC does not.

This fixes the issue with GCC:

--- a/Source/JavaScriptCore/dfg/DFGAbstractValue.h
+++ b/Source/JavaScriptCore/dfg/DFGAbstractValue.h
@@ -191,21 +191,21 @@ struct AbstractValue {
     
     static AbstractValue heapTop()
     {
-        AbstractValue result;
+        static AbstractValue result;
         result.makeHeapTop();
         return result;
     }
     
     static AbstractValue bytecodeTop()
     {
-        AbstractValue result;
+        static AbstractValue result;
         result.makeBytecodeTop();
         return result;
     }
     
     static AbstractValue fullTop()
     {
-        AbstractValue result;
+        static AbstractValue result;
         result.makeFullTop();
         return result;
     }



Now I wonder if this is the best approach (declaring it as static), or it will be better to directly bzero the structure on the constructor, or perhaps it will be better to modify the assert to check only the values of the members of the structure.


[1] https://gustedt.wordpress.com/2012/10/24/c11-defects-initialization-of-padding/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224876</commentid>
    <comment_count>11</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-08-30 22:57:22 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; (In reply to comment #7)
&gt; &gt; Ok.
&gt; &gt; Third guess, there is now 4 bytes of padding after the ArrayModes
&gt; &gt; m_arrayModes
&gt; &gt; field, maybe those aren&apos;t getting zeroed out? And for some reason, clang
&gt; &gt; zeroes
&gt; &gt; them out.
&gt; 
&gt; It seems that the standard only guarantees that the padding in structures is
&gt; zero-initialized on some very specific cases [1]. In the rest of cases it is
&gt; undefined behaviour. And this seems to be one of this cases. That explains
&gt; why clang is zero-initializing the padding of the structure, but GCC does
&gt; not.

Stack allocated objects are never zero-initialized by the compiler, I think, their members are initialized on construction, so it&apos;s expected that the padding is not initialized. AbstractValue adds vector and hash traits to ensure that they are initialized with memset when allocated by a vector or hash objects. In such cases the passing is always 0 because memset fills from the base pointer to the sizeof().

&gt; This fixes the issue with GCC:
&gt; 
&gt; --- a/Source/JavaScriptCore/dfg/DFGAbstractValue.h
&gt; +++ b/Source/JavaScriptCore/dfg/DFGAbstractValue.h
&gt; @@ -191,21 +191,21 @@ struct AbstractValue {
&gt;      
&gt;      static AbstractValue heapTop()
&gt;      {
&gt; -        AbstractValue result;
&gt; +        static AbstractValue result;
&gt;          result.makeHeapTop();
&gt;          return result;
&gt;      }
&gt;      
&gt;      static AbstractValue bytecodeTop()
&gt;      {
&gt; -        AbstractValue result;
&gt; +        static AbstractValue result;
&gt;          result.makeBytecodeTop();
&gt;          return result;
&gt;      }
&gt;      
&gt;      static AbstractValue fullTop()
&gt;      {
&gt; -        AbstractValue result;
&gt; +        static AbstractValue result;
&gt;          result.makeFullTop();
&gt;          return result;
&gt;      }
&gt; 
&gt; 
&gt; 
&gt; Now I wonder if this is the best approach (declaring it as static), or it
&gt; will be better to directly bzero the structure on the constructor, or
&gt; perhaps it will be better to modify the assert to check only the values of
&gt; the members of the structure.

I guess we really want a new AbstractValue object every time those methods are called. I think the check is what is wrong, not the callers.

Could we remove that check while we find a better solution? The GTK+ Debug bot has exited early for two days

&gt; 
&gt; [1]
&gt; https://gustedt.wordpress.com/2012/10/24/c11-defects-initialization-of-
&gt; padding/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1225003</commentid>
    <comment_count>12</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2016-08-31 11:22:34 -0700</bug_when>
    <thetext>Fixed in https://trac.webkit.org/changeset/205254.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>