<?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>199684</bug_id>
          
          <creation_ts>2019-07-10 13:58:29 -0700</creation_ts>
          <short_desc>Assigning object property twice in a loop breaks JSCore on powerpc64 and s390x</short_desc>
          <delta_ts>2019-07-17 10:54: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>JavaScriptCore</component>
          <version>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>195181</dup_id>
          
          <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="Dmitry Shachnev">mitya57</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>berto</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1551824</commentid>
    <comment_count>0</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2019-07-10 13:58:29 -0700</bug_when>
    <thetext>Test case with WebKitGTK+:

#include &lt;jsc/jsc.h&gt;

int main() {
    JSCContext *context = jsc_context_new();
    const char *script =
        &quot;for (var i = 0; i &lt; 2; i++) {\n&quot;
        &quot;    var foo = {};\n&quot;
        &quot;    foo.bar = null;\n&quot;
        &quot;}\n&quot;
        &quot;888\n&quot;;
    JSCValue *value = jsc_context_evaluate(context, script, -1);
    gint32 value_int = jsc_value_to_int32(value);
    g_message(&quot;Value is %d\n&quot;, value_int);
    return 0;
}

Expected result: &quot;Value is 888&quot; is printed.

Instead it crashes on powerpc64 (little endian) and s390x. Here is a stacktrace from s390x:

#0  0x000003fffd8739f6 in JSC::LLInt::CLoop::execute(JSC::OpcodeID, void*, JSC::VM*, JSC::ProtoCallFrame*, bool) ()
    at DerivedSources/JavaScriptCore/LLIntAssembly.h:6044
#1  0x000003fffd88dd10 in vmEntryToJavaScript() ()
    at ../Source/JavaScriptCore/llint/LLIntThunks.cpp:108
#2  0x000003fffd85cb44 in JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) () at ../Source/JavaScriptCore/jit/JITCodeInlines.h:38
#3  0x000003fffd85cb44 in JSC::Interpreter::executeProgram(JSC::SourceCode const&amp;, JSC::ExecState*, JSC::JSObject*) ()
    at ../Source/JavaScriptCore/interpreter/Interpreter.cpp:834
#4  0x000003fffd9fac82 in JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&amp;, JSC::JSValue, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;) ()
    at ../Source/JavaScriptCore/runtime/Completion.cpp:137
#5  0x000003fffd9fae50 in JSC::profiledEvaluate(JSC::ExecState*, JSC::ProfilingReason, JSC::SourceCode const&amp;, JSC::JSValue, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;)
    () at ../Source/JavaScriptCore/runtime/Completion.cpp:153
#6  0x000003fffd649278 in JSEvaluateScript() ()
    at ../Source/JavaScriptCore/API/JSBase.cpp:70
#7  0x000003fffd613910 in evaluateScriptInContext() ()
    at ../Source/JavaScriptCore/API/glib/JSCContext.cpp:824
#8  0x000003fffd614e2a in jsc_context_evaluate_with_source_uri() ()
    at ../Source/JavaScriptCore/API/glib/JSCContext.cpp:847
#9  0x000003fffd614efa in jsc_context_evaluate() ()
    at ../Source/JavaScriptCore/API/glib/JSCContext.cpp:817
#10 0x0000000100000936 in main () at test_jscore.c:12

This stacktrace is from Debian unstable, WebKitGTK version is 2.24.3.

According to our CI logs, it regressed somewhere between 2.23.91 and 2.23.92.

See https://bugs.debian.org/931807 for my original report that has a more complicate test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552406</commentid>
    <comment_count>1</comment_count>
    <who name="Alberto Garcia">berto</who>
    <bug_when>2019-07-12 07:11:03 -0700</bug_when>
    <thetext>Yeah, I can reproduce this simply by saving the following piece of code to a test.js file and running it with /usr/bin/jsc.

for (var i = 0; i &lt; 2; i++) {
    var foo = {};
    foo.bar = null;
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552408</commentid>
    <comment_count>2</comment_count>
    <who name="Alberto Garcia">berto</who>
    <bug_when>2019-07-12 07:32:34 -0700</bug_when>
    <thetext>A slightly more detailed backtrace (using the test case from my previous comment):

JSC::LLInt::CLoop::execute (entryOpcodeID=JSC::llint_vm_entry_to_javascript, 
    executableAddress=0x3fffb6db9fc0 &lt;JSC::LLInt::CLoop::execute(JSC::OpcodeID, void*, JSC::VM*, JSC::ProtoCallFrame*, bool)+26076&gt;, vm=0x3fffb2b10010, protoCallFrame=0x3fffffffe1b0, 
    isInitializationPass=false) at DerivedSources/JavaScriptCore/LLIntAssembly.h:6047
6047        t2 = *CAST&lt;int64_t*&gt;(t2.i8p() + 32);                     // Source/JavaScriptCore/llint/LowLevelInterpreter64.asm:1368
(gdb) bt
#0  0x00003fffb6def1e8 in JSC::LLInt::CLoop::execute(JSC::OpcodeID, void*, JSC::VM*, JSC::ProtoCallFrame*, bool)
    (entryOpcodeID=JSC::llint_vm_entry_to_javascript, executableAddress=0x3fffb6db9fc0 &lt;JSC::LLInt::CLoop::execute(JSC::OpcodeID, void*, JSC::VM*, JSC::ProtoCallFrame*, bool)+26076&gt;, vm=0x3fffb2b10010, protoCallFrame=0x3fffffffe1b0, isInitializationPass=false) at DerivedSources/JavaScriptCore/LLIntAssembly.h:6047
#1  0x00003fffb6eb58dc in JSC::vmEntryToJavaScript(void*, JSC::VM*, JSC::ProtoCallFrame*)
    (executableAddress=0x3fffb6db9fc0 &lt;JSC::LLInt::CLoop::execute(JSC::OpcodeID, void*, JSC::VM*, JSC::ProtoCallFrame*, bool)+26076&gt;, vm=0x3fffb2b10010, protoCallFrame=0x3fffffffe1b0)
    at ../Source/JavaScriptCore/llint/LLIntThunks.cpp:108
#2  0x00003fffb6d8981c in JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) (protoCallFrame=0x3fffffffe1b0, vm=0x3fffb2b10010, this=0x1001569e0)
    at ../Source/JavaScriptCore/jit/JITCodeInlines.h:38
#3  0x00003fffb6d8981c in JSC::Interpreter::executeProgram(JSC::SourceCode const&amp;, JSC::ExecState*, JSC::JSObject*)
    (this=0x10012aba0, source=..., callFrame=0x3fffb2690048, thisObj=0x3fffb2570280) at ../Source/JavaScriptCore/interpreter/Interpreter.cpp:834
#4  0x00003fffb7215b34 in JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&amp;, JSC::JSValue, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;)
    (exec=0x3fffb2690048, source=..., thisValue=..., returnedException=...) at ../Source/JavaScriptCore/runtime/Completion.cpp:137
#5  0x000000010005fed0 in runWithOptions(GlobalObject*, CommandLine&amp;, bool&amp;) (globalObject=0x3fffb2690000, options=..., success=@0x3fffffffef03: true)
    at ../Source/JavaScriptCore/jsc.cpp:2584
#6  0x0000000100061e54 in &lt;lambda(JSC::VM&amp;, GlobalObject*, bool&amp;)&gt;::operator()(JSC::VM &amp;, GlobalObject *, bool &amp;) const (__closure=0x3ffffffff000, 
    vm=..., globalObject=0x3fffb2690000, success=@0x3fffffffef03: true) at ../Source/JavaScriptCore/jsc.cpp:3050
#7  0x0000000100063f08 in runJSC&lt;jscmain(int, char**)::&lt;lambda(JSC::VM&amp;, GlobalObject*, bool&amp;)&gt; &gt;(const CommandLine &amp;, bool, const &lt;lambda(JSC::VM&amp;, GlobalObject*, bool&amp;)&gt; &amp;)
    (options=..., isWorker=false, func=...) at ../Source/JavaScriptCore/jsc.cpp:2908
#8  0x0000000100061f38 in jscmain(int, char**) (argc=2, argv=0x3ffffffff508) at ../Source/JavaScriptCore/jsc.cpp:3043
#9  0x00000001000541d8 in main(int, char**) (argc=2, argv=0x3ffffffff508) at ../Source/JavaScriptCore/jsc.cpp:2408</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1553463</commentid>
    <comment_count>3</comment_count>
    <who name="Alberto Garcia">berto</who>
    <bug_when>2019-07-17 01:57:39 -0700</bug_when>
    <thetext>I bisected this problem, jsc started to crash in r242469 (which is a cherry-pick of r242096 for the WebKitGTK 2.24 branch):

https://trac.webkit.org/changeset/242096/webkit</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1553470</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2019-07-17 02:58:35 -0700</bug_when>
    <thetext>(In reply to Alberto Garcia from comment #3)
&gt; I bisected this problem, jsc started to crash in r242469 (which is a
&gt; cherry-pick of r242096 for the WebKitGTK 2.24 branch):
&gt; 
&gt; https://trac.webkit.org/changeset/242096/webkit

hmm, but does it happen in trunk too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1553488</commentid>
    <comment_count>5</comment_count>
    <who name="Alberto Garcia">berto</who>
    <bug_when>2019-07-17 05:14:53 -0700</bug_when>
    <thetext>(In reply to Carlos Garcia Campos from comment #4)
&gt; hmm, but does it happen in trunk too?

WebKitGTK 2.25.2 does not build in ppc64el so I supposed that trunk
does not build either, but fortunately jsc does build fine.

So it seems that the problem was already fixed in r242215. I confirm
that if I cherry-pick that patch to the webkitgtk 2.24 branch the
problem disappears (in ppc64el at least).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1553493</commentid>
    <comment_count>6</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2019-07-17 05:43:37 -0700</bug_when>
    <thetext>(In reply to Alberto Garcia from comment #5)
&gt; (In reply to Carlos Garcia Campos from comment #4)
&gt; &gt; hmm, but does it happen in trunk too?
&gt; 
&gt; WebKitGTK 2.25.2 does not build in ppc64el so I supposed that trunk
&gt; does not build either, but fortunately jsc does build fine.
&gt; 
&gt; So it seems that the problem was already fixed in r242215. I confirm
&gt; that if I cherry-pick that patch to the webkitgtk 2.24 branch the
&gt; problem disappears (in ppc64el at least).

Great, please add that one to the wiki for 2.24.4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1553494</commentid>
    <comment_count>7</comment_count>
    <who name="Alberto Garcia">berto</who>
    <bug_when>2019-07-17 05:50:24 -0700</bug_when>
    <thetext>(In reply to Carlos Garcia Campos from comment #6)
&gt; Great, please add that one to the wiki for 2.24.4

Done, thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1553496</commentid>
    <comment_count>8</comment_count>
    <who name="Alberto Garcia">berto</who>
    <bug_when>2019-07-17 05:58:56 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 195181 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1553511</commentid>
    <comment_count>9</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-07-17 08:26:09 -0700</bug_when>
    <thetext>Good job Berto!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1553572</commentid>
    <comment_count>10</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2019-07-17 10:54:00 -0700</bug_when>
    <thetext>&gt; So it seems that the problem was already fixed in r242215. I confirm
&gt; that if I cherry-pick that patch to the webkitgtk 2.24 branch the
&gt; problem disappears (in ppc64el at least).

Nice to know, thanks a lot for digging that!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>