<?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>12535</bug_id>
          
          <creation_ts>2007-02-01 13:23:01 -0800</creation_ts>
          <short_desc>Stack-optimizing compilers can trick GC into freeing in-use objects</short_desc>
          <delta_ts>2007-03-30 15:45:20 -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>420+</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P1</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Huan Ren">huanr</reporter>
          <assigned_to name="Huan Ren">huanr</assigned_to>
          <cc>ap</cc>
    
    <cc>erowe</cc>
    
    <cc>fishd</cc>
    
    <cc>ggaren</cc>
    
    <cc>huanr</cc>
    
    <cc>ian.eng.webkit</cc>
    
    <cc>KwhiteRight</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>29120</commentid>
    <comment_count>0</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-02-01 13:23:01 -0800</bug_when>
    <thetext>on windows platform, I observed quite a few crashes at kjs_pcre_exec(). the cause has been traced back to previous call at 

KJS::FunctionCallDotNode::evaluate
-&gt; KJS::StringImp::toObject
-&gt; KJS::StringInstance::StringInstance
-&gt; KJS::jsString

where the garbage collector frees an object in use. This incorrect free casues memory corruption and leads to later crash at kjs_pcre_exec()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29122</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-02-01 13:37:23 -0800</bug_when>
    <thetext>Please post an example URL or a reduced test case to this bug.  Thanks!

Also, what are you using to test WebKit on Windows?  Spinneret or another application?

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29123</commentid>
    <comment_count>2</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-02-01 13:49:51 -0800</bug_when>
    <thetext>the bug repros randomly as it depends on when GC is invoked.  my proposed fix is in kjs::FunctionCallDotNode::evaluate

JSValue *FunctionCallDotNode::evaluate(ExecState *exec)
{
  JSValue *baseVal = base-&gt;evaluate(exec);

  //
  // In the optimized release build, the compiler may discard the reference 
  // to baseObj immediately after it resolves the address of 
  // baseVal-&gt;toObject(). This makes baseVal subject to garbage collection
  // inside baseVal-&gt;toObject().
  // If the runtime type of baseVal is StringImp, StringImp::toObject() will
  // invoke a chain of function calls that allocate new objects while passing
  // its member variable val (type UString) as a parameter.
  // If Garbage Collector is triggered during memory allocation, baseVal is 
  // deleted and thus its member val, which is passed as a parameter, becomes 
  // invalid. When newly created object references val, we will have memory 
  // corruption.
  //
  Collector::protect(baseVal);

  JSObject *baseObj = baseVal-&gt;toObject(exec);

  Collector::unprotect(baseVal);
  
...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29127</commentid>
    <comment_count>3</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-02-01 14:55:38 -0800</bug_when>
    <thetext>The is caused by a general unsafe practice in KJS code: take the address of a field in a JSCell object, and passed it around. For example:
in KJS internal.h

class StringImp : public JSCell {
 private:
  UString val;
}

In StringImp::toObject(ExecState* exec);, val is passed as a reference to the constructor StringInstance::StringInstance. Unfortunately, the compiler was smart enough that it thought this pointer is not used anymore, and put it in a volatile register. The constructor triggers GC, and this object is freed. Now the address of &apos;val&apos; points to an invalid address.
 
The problem is that the garbage collector only compares pointers to the start address of JSCell&apos;s. If there is a pointer to the middle of a JSCell, it won&apos;t be traced. One partial fix I&apos;d suggest is to treat a JSCell as live if there is a root pointer pointing to its body. This will allow taking addresses of a field in a JSCell and passing it to stack/local variables. BUT this cannot solve the problem when such an address is assigned to somewhere in the heap.

Comments?

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29131</commentid>
    <comment_count>4</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2007-02-01 15:12:47 -0800</bug_when>
    <thetext>(In reply to comment #2)

Anrong, did you mean to say that the compiler may discard the reference to &apos;baseObj&apos; or to &apos;baseVal&apos;? Your reasoning points to &apos;baseVal&apos;, not &apos;baseObj&apos;. Would this bug persist if toObject() made use of &apos;this&apos;, prohibiting the compiler from optimizing out baseVal?

I don&apos;t think &apos;Collector::protect(baseVal);&apos; is a very good solution. It&apos;s inefficient, and it doesn&apos;t seem to address the root cause of the problem, which may affect lots of different parts of the code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29132</commentid>
    <comment_count>5</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2007-02-01 15:23:28 -0800</bug_when>
    <thetext>(In reply to comment #3)

I don&apos;t think pointers in the (non-GC) heap are a consideration. You already have to protect them explicitly.

Honoring pointers to object bodies as pointers to the objects themselves seems like it would solve the problem. I worry that it might increase marking overhead substantially because we would start honoring more &apos;fake&apos; pointers.

Another solution would be for objects to create an explicit, volatile stack reference to &apos;this&apos; before handing off pointers to their internals. Yet another solution (in this particular case) would be to store a temporary UString on the stack, and pass that UString by reference.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29135</commentid>
    <comment_count>6</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-02-01 16:07:37 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #3)
&gt; 
&gt; I don&apos;t think pointers in the (non-GC) heap are a consideration. You already
&gt; have to protect them explicitly.
&gt; 
&gt; Honoring pointers to object bodies as pointers to the objects themselves seems
&gt; like it would solve the problem. I worry that it might increase marking
&gt; overhead substantially because we would start honoring more &apos;fake&apos; pointers.

I think the overhead might no much. Instead of checking 
if (offset % sizeof(CollectorCell) == 0)
It does some arithmatic calculation:
  x = cellStart + (offset / sizeof(CollectorCell)) * sizeof(CollectorCell);

We need some additional work for oversized cells. Size infomation is needed. We can malloc an additional int before the requested size, and store the cell size into it. This works like a Java array with length in its header. BTW, I experimented this change, and it works properly.

Overall, these only cost a few instruction cycles when scanning root pointers. I think it is not a big issue.

I will post a patch later.

&gt; 
&gt; Another solution would be for objects to create an explicit, volatile stack
&gt; reference to &apos;this&apos; before handing off pointers to their internals. Yet another
&gt; solution (in this particular case) would be to store a temporary UString on the
&gt; stack, and pass that UString by reference.
&gt; 

(In reply to comment #5)
&gt; (In reply to comment #3)
&gt; 
&gt; I don&apos;t think pointers in the (non-GC) heap are a consideration. You already
&gt; have to protect them explicitly.
&gt; 
&gt; Honoring pointers to object bodies as pointers to the objects themselves seems
&gt; like it would solve the problem. I worry that it might increase marking
&gt; overhead substantially because we would start honoring more &apos;fake&apos; pointers.
&gt; 
&gt; Another solution would be for objects to create an explicit, volatile stack
&gt; reference to &apos;this&apos; before handing off pointers to their internals. Yet another
&gt; solution (in this particular case) would be to store a temporary UString on the
&gt; stack, and pass that UString by reference.
&gt; 

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29139</commentid>
    <comment_count>7</comment_count>
      <attachid>12864</attachid>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-02-01 16:53:43 -0800</bug_when>
    <thetext>Created attachment 12864
trace pointers into bodies

The patch doesn&apos;t following the format required by webkit.org, I put it here for discussion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29141</commentid>
    <comment_count>8</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-02-01 17:23:39 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt;
&gt; &gt; Honoring pointers to object bodies as pointers to the objects themselves seems
&gt; &gt; like it would solve the problem. I worry that it might increase marking
&gt; &gt; overhead substantially because we would start honoring more &apos;fake&apos; pointers.
&gt; 
&gt; I think the overhead might no much. Instead of checking 
&gt; if (offset % sizeof(CollectorCell) == 0)
&gt; It does some arithmatic calculation:
&gt;   x = cellStart + (offset / sizeof(CollectorCell)) * sizeof(CollectorCell);
&gt; 
&gt; We need some additional work for oversized cells. Size infomation is needed. We
&gt; can malloc an additional int before the requested size, and store the cell size
&gt; into it. This works like a Java array with length in its header. BTW, I
&gt; experimented this change, and it works properly.
&gt; 
&gt; Overall, these only cost a few instruction cycles when scanning root pointers.
&gt; I think it is not a big issue.

The problem isn&apos;t the extra instructions to do the math. It&apos;s the cost of extra false positives. Note that right now before scanning the blocks we check:

    if (IS_CELL_ALIGNED(x) &amp;&amp; x) {

IS_CELL_ALIGNED checks for 8-byte alignment, which is not valid if we want to honor arbitrary pointers into object bodies.

If we checked every nonzero value on the stack, we would do the block loop a lot more, which would be a significant performance regression.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29143</commentid>
    <comment_count>9</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-02-01 18:07:28 -0800</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #2)
&gt; 
&gt; Anrong, did you mean to say that the compiler may discard the reference to
&gt; &apos;baseObj&apos; or to &apos;baseVal&apos;? Your reasoning points to &apos;baseVal&apos;, not &apos;baseObj&apos;.
&gt; Would this bug persist if toObject() made use of &apos;this&apos;, prohibiting the
&gt; compiler from optimizing out baseVal?
&gt; 
&gt; I don&apos;t think &apos;Collector::protect(baseVal);&apos; is a very good solution. It&apos;s
&gt; inefficient, and it doesn&apos;t seem to address the root cause of the problem,
&gt; which may affect lots of different parts of the code.
&gt; 

Geoffrey, 

I meant baseVal. The bug goes away if toObject() made use of &apos;this&apos; thus effectively lock baseVal. 
Collector::protect(baseVal) fixes this code path. if this is a common pattern then other solutions being discussed here may be better if they have no global impact.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29162</commentid>
    <comment_count>10</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-02-01 22:07:47 -0800</bug_when>
    <thetext>(In reply to comment #9)
&gt; (In reply to comment #4)
&gt; &gt; (In reply to comment #2)
&gt; &gt; 
&gt; &gt; Anrong, did you mean to say that the compiler may discard the reference to
&gt; &gt; &apos;baseObj&apos; or to &apos;baseVal&apos;? Your reasoning points to &apos;baseVal&apos;, not &apos;baseObj&apos;.
&gt; &gt; Would this bug persist if toObject() made use of &apos;this&apos;, prohibiting the
&gt; &gt; compiler from optimizing out baseVal?
&gt; &gt; 
&gt; &gt; I don&apos;t think &apos;Collector::protect(baseVal);&apos; is a very good solution. It&apos;s
&gt; &gt; inefficient, and it doesn&apos;t seem to address the root cause of the problem,
&gt; &gt; which may affect lots of different parts of the code.
&gt; &gt; 
&gt; 
&gt; Geoffrey, 
&gt; 
&gt; I meant baseVal. The bug goes away if toObject() made use of &apos;this&apos; thus
&gt; effectively lock baseVal. 
&gt; Collector::protect(baseVal) fixes this code path. if this is a common pattern
&gt; then other solutions being discussed here may be better if they have no global
&gt; impact.
&gt; 

The following fix has also been verified:

#if COMPILER(MSVC)
#pragma optimize(&quot;&quot;, off)
#endif
JSObject *StringImp::toObject(ExecState *exec) const
{
    const StringImp *ptr = this;
    return new StringInstance(exec-&gt;lexicalInterpreter()-&gt;builtinStringPrototype(), ptr-&gt;val);
}
#if COMPILER(MSVC)
#pragma optimize(&quot;&quot;, on)
#endif

I agree this fix is better than Collector::protect as it addresses all calling path. Turning off optimization has little cost here since the function is simple enough. (It turns out the compiler will optimize the variable away even we declare the local to be volatile)

I could provide the patch. 
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29164</commentid>
    <comment_count>11</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2007-02-01 22:50:36 -0800</bug_when>
    <thetext>Is that really the only function hit by this bug?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29220</commentid>
    <comment_count>12</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-02-02 11:14:58 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; (In reply to comment #6)
&gt; &gt;
&gt; &gt; &gt; Honoring pointers to object bodies as pointers to the objects themselves seems
&gt; &gt; &gt; like it would solve the problem. I worry that it might increase marking
&gt; &gt; &gt; overhead substantially because we would start honoring more &apos;fake&apos; pointers.
&gt; &gt; 
&gt; &gt; I think the overhead might no much. Instead of checking 
&gt; &gt; if (offset % sizeof(CollectorCell) == 0)
&gt; &gt; It does some arithmatic calculation:
&gt; &gt;   x = cellStart + (offset / sizeof(CollectorCell)) * sizeof(CollectorCell);
&gt; &gt; 
&gt; &gt; We need some additional work for oversized cells. Size infomation is needed. We
&gt; &gt; can malloc an additional int before the requested size, and store the cell size
&gt; &gt; into it. This works like a Java array with length in its header. BTW, I
&gt; &gt; experimented this change, and it works properly.
&gt; &gt; 
&gt; &gt; Overall, these only cost a few instruction cycles when scanning root pointers.
&gt; &gt; I think it is not a big issue.
&gt; 
&gt; The problem isn&apos;t the extra instructions to do the math. It&apos;s the cost of extra
&gt; false positives. Note that right now before scanning the blocks we check:
&gt; 
&gt;     if (IS_CELL_ALIGNED(x) &amp;&amp; x) {
&gt; 
&gt; IS_CELL_ALIGNED checks for 8-byte alignment, which is not valid if we want to
&gt; honor arbitrary pointers into object bodies.
&gt; 
&gt; If we checked every nonzero value on the stack, we would do the block loop a
&gt; lot more, which would be a significant performance regression.
&gt; 

Maciej, is there a performance test suite to measure how much overhead it would be? Maybe we can think about using a interval tree instead of the block loop to speed up the range test.

Another solution is to fix these classes returning field addresses. It may not be hard to do, but it cannot prevent violations in the future.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29222</commentid>
    <comment_count>13</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-02-02 11:18:25 -0800</bug_when>
    <thetext>(In reply to comment #11)
&gt; Is that really the only function hit by this bug?
&gt; 

    StringImp::toObject is the only one I discovered during debugging. Is passing member variables of JSCell in function call a common pattern in kjs?. I did a quick search on other toObject() functions under JavaScriptCore/kjs and did not find this issue.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28997</commentid>
    <comment_count>14</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-02-03 03:50:18 -0800</bug_when>
    <thetext>&gt; #if COMPILER(MSVC)
&gt; #pragma optimize(&quot;&quot;, off)
&gt; #endif

Is there a more cross-platform way to defeat the stack re-use? Perhaps coping the value into memory allocated by alloca() could help.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27711</commentid>
    <comment_count>15</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-02-04 11:36:33 -0800</bug_when>
    <thetext>We use JavaScript iBench (not publicly available) and the 24fun BenchJs benchmark: http://www.24fun.com/downloadcenter/benchjs/benchjs.html

I&apos;m happy to performance test any proposed patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27649</commentid>
    <comment_count>16</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-02-04 11:49:26 -0800</bug_when>
    <thetext>&lt;rdar://problem/4975127&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27450</commentid>
    <comment_count>17</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-02-05 10:53:21 -0800</bug_when>
    <thetext>(In reply to comment #14)
&gt; &gt; #if COMPILER(MSVC)
&gt; &gt; #pragma optimize(&quot;&quot;, off)
&gt; &gt; #endif
&gt; 
&gt; Is there a more cross-platform way to defeat the stack re-use? Perhaps coping
&gt; the value into memory allocated by alloca() could help.
&gt; 
If we use alloca(), there is still a possibility that the compiler may optimize it away, just like what it does to baseVal described earlier. There seems no gruantee to prevent all compilers from doing that. 

For compilers used on other platform, we can consider also using pragma to turn off optimization, probably with different syntax, for this funciton if needed. 
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27396</commentid>
    <comment_count>18</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-02-05 11:30:12 -0800</bug_when>
    <thetext>(In reply to comment #13)
&gt; (In reply to comment #11)
&gt; &gt; Is that really the only function hit by this bug?
&gt; &gt; 
&gt; 
&gt;     StringImp::toObject is the only one I discovered during debugging. Is
&gt; passing member variables of JSCell in function call a common pattern in kjs?. I
&gt; did a quick search on other toObject() functions under JavaScriptCore/kjs and
&gt; did not find this issue.
&gt; 

I sent my reply to Mark. Here is it again:

Please correct me if I am wrong.

A member function returning the address of/a reference to a field
could also be a violator.
I found a few cases:
 
class InternalFunctionImp

  const Identifier&amp; functionName() const { return m_name; }
 private:
  Identifier m_name;

class Identifier {
  const UString&amp; ustring() const { return _ustring; }
 private:
  UString _ustring;
}

One can write some code like:
  InternalFunctionImpl* func = new InternalFunctionImpl();
  Identifier* id = func-&gt;functionName();
  UString* v = id-&gt;ustring();
  func = NULL;
  // trigger GC here
  // now id and v points to invalid memory

Other similar cases:
class FunctionImpl:
  const ScopeChain&amp; scope() const { return _scope; }
 private:
  ScopeChain _scope;

I went through these files so far.


</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27343</commentid>
    <comment_count>19</comment_count>
      <attachid>12947</attachid>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-02-05 14:16:38 -0800</bug_when>
    <thetext>Created attachment 12947
a patch for preformance test

Maciej, I created this patch by using svn-create-patch script. Please use this patch to measure the performance on benchmarks you have.

New code can be turned on/off by changing the value of ALLOW_INNER_POINTERS to 1/0.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25382</commentid>
    <comment_count>20</comment_count>
      <attachid>12947</attachid>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-02-07 00:48:02 -0800</bug_when>
    <thetext>Comment on attachment 12947
a patch for preformance test

Flagging review? for someone at Apple (probably me) to perf-test this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24537</commentid>
    <comment_count>21</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-02-09 18:10:32 -0800</bug_when>
    <thetext>I measured and this patch causes a 2% performance regression on the iBench, at least on Mac OS X (where it is not even needed since the compiler won&apos;t optimize out object pointers like that). I think this needs to be addressed more along the lines of Anrong Hu&apos;s approach, where we keep the compiler from dropping the pointer. I think copying to alloca()&apos;d memory, or even just keeping it in a struct on the stack might do it, and something that works for current MSVC seems good enough.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24532</commentid>
    <comment_count>22</comment_count>
      <attachid>12947</attachid>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-02-09 22:46:12 -0800</bug_when>
    <thetext>Comment on attachment 12947
a patch for preformance test

r- for reasons stated above</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24334</commentid>
    <comment_count>23</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-02-10 22:19:24 -0800</bug_when>
    <thetext>(In reply to comment #21)
&gt; I measured and this patch causes a 2% performance regression on the iBench, at
&gt; least on Mac OS X (where it is not even needed since the compiler won&apos;t
&gt; optimize out object pointers like that). I think this needs to be addressed
&gt; more along the lines of Anrong Hu&apos;s approach, where we keep the compiler from
&gt; dropping the pointer. I think copying to alloca()&apos;d memory, or even just
&gt; keeping it in a struct on the stack might do it, and something that works for
&gt; current MSVC seems good enough.
&gt; 

I am fine with Anrong&apos;s approach, but that won&apos;t cure the problem. What about another solution: fixing classes that return the address/a reference to a field?
Like I mentioned in Comment #18, a method can return the value instead of a reference/address of the field.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23177</commentid>
    <comment_count>24</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-02-15 12:41:43 -0800</bug_when>
    <thetext>(In reply to comment #23)
&gt; (In reply to comment #21)
&gt; &gt; I measured and this patch causes a 2% performance regression on the iBench, at
&gt; &gt; least on Mac OS X (where it is not even needed since the compiler won&apos;t
&gt; &gt; optimize out object pointers like that). I think this needs to be addressed
&gt; &gt; more along the lines of Anrong Hu&apos;s approach, where we keep the compiler from
&gt; &gt; dropping the pointer. I think copying to alloca()&apos;d memory, or even just
&gt; &gt; keeping it in a struct on the stack might do it, and something that works for
&gt; &gt; current MSVC seems good enough.
&gt; &gt; 
&gt; 
&gt; I am fine with Anrong&apos;s approach, but that won&apos;t cure the problem. What about
&gt; another solution: fixing classes that return the address/a reference to a
&gt; field?
&gt; Like I mentioned in Comment #18, a method can return the value instead of a
&gt; reference/address of the field.
&gt; 


I will submit a fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23179</commentid>
    <comment_count>25</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-02-15 13:15:26 -0800</bug_when>
    <thetext>(In reply to comment #24)
&gt; (In reply to comment #23)
&gt; &gt; (In reply to comment #21)
&gt; &gt; &gt; I measured and this patch causes a 2% performance regression on the iBench, at
&gt; &gt; &gt; least on Mac OS X (where it is not even needed since the compiler won&apos;t
&gt; &gt; &gt; optimize out object pointers like that). I think this needs to be addressed
&gt; &gt; &gt; more along the lines of Anrong Hu&apos;s approach, where we keep the compiler from
&gt; &gt; &gt; dropping the pointer. I think copying to alloca()&apos;d memory, or even just
&gt; &gt; &gt; keeping it in a struct on the stack might do it, and something that works for
&gt; &gt; &gt; current MSVC seems good enough.
&gt; &gt; &gt; 
&gt; &gt; 
&gt; &gt; I am fine with Anrong&apos;s approach, but that won&apos;t cure the problem. What about
&gt; &gt; another solution: fixing classes that return the address/a reference to a
&gt; &gt; field?
&gt; &gt; Like I mentioned in Comment #18, a method can return the value instead of a
&gt; &gt; reference/address of the field.
&gt; &gt; 
&gt; 
&gt; 
&gt; I will submit a fix.
&gt; 

I&apos;d like to assign this bug to me. There are also other cross-platform p1 bugs I  want to investigate. Is there a way to assign bugs to myself through Bugzilla?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23184</commentid>
    <comment_count>26</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2007-02-15 14:17:24 -0800</bug_when>
    <thetext>I think you can just use the &quot;Reassign&quot; radio button.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22769</commentid>
    <comment_count>27</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-02-20 00:36:46 -0800</bug_when>
    <thetext>Returning a value instead of a pointer into the object seems fine. We should probably document that as a rule.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22776</commentid>
    <comment_count>28</comment_count>
    <who name="Ed Rowe">erowe</who>
    <bug_when>2007-02-20 01:17:58 -0800</bug_when>
    <thetext>Honoring pointers to object bodies as pointers to the objects themselves would solve THIS problem but not the general class of issues. Imagine if rather than passing a reference to a member UString to jsString() we were passing a file handle, or a raw pointer (that needs to be deleted) or basically any sort of state whose lifetime is bound to the JSValue and which is not a pointer into the JSValue&apos;s memory. In any of these cases, the compiler would still optimize away any pointer to the object or its body, and we&apos;d still have the problem.

(In reply to comment #5)
&gt; (In reply to comment #3)
&gt; I don&apos;t think pointers in the (non-GC) heap are a consideration. You already
&gt; have to protect them explicitly.
&gt; Honoring pointers to object bodies as pointers to the objects themselves seems
&gt; like it would solve the problem. I worry that it might increase marking
&gt; overhead substantially because we would start honoring more &apos;fake&apos; pointers.
&gt; Another solution would be for objects to create an explicit, volatile stack
&gt; reference to &apos;this&apos; before handing off pointers to their internals. Yet another
&gt; solution (in this particular case) would be to store a temporary UString on the
&gt; stack, and pass that UString by reference.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20259</commentid>
    <comment_count>29</comment_count>
      <attachid>13507</attachid>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-03-06 22:38:40 -0800</bug_when>
    <thetext>Created attachment 13507
Proposing fix

A more cross-platform fix as suggested: using alloca() and putting the object reference onto stack.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20202</commentid>
    <comment_count>30</comment_count>
      <attachid>13507</attachid>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-03-07 00:36:31 -0800</bug_when>
    <thetext>Comment on attachment 13507
Proposing fix

1) This will break the build on mac and linux since they call it alloca() not _alloca() and prototype it in alloca.h, not malloc.h. Please fix that.

2) Is this definitely the only place affected? It looks like further up in the comments, Ian Eng identified more potential trouble spots.

3) To fix just this one particular case, wouldn&apos;t it be simpler to just copy val to a local UString variable on the stack? That avoids relying on something unportable like alloca().

UString valCopy = val;
return new StringInstance(exec-&gt;lexicalInterpreter()-&gt;builtinStringPrototype(), valCopy);

r- to at least address comment 1, since this will break the build otherwise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20036</commentid>
    <comment_count>31</comment_count>
      <attachid>13519</attachid>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-03-07 11:33:41 -0800</bug_when>
    <thetext>Created attachment 13519
Fix</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20037</commentid>
    <comment_count>32</comment_count>
    <who name="Huan Ren">huanr</who>
    <bug_when>2007-03-07 11:34:38 -0800</bug_when>
    <thetext>(In reply to comment #31)
&gt; Created an attachment (id=13519) [edit]
&gt; Fix
&gt; 

Re: (2)
As a recap, the calling pattern that makes this happen is: A-&gt;B-&gt;C.
  (a) In A, the reference to B is optimized away.
  (b) In B, its data member is passed as parameter to C.
  (c) C does sth that may trigger gc, and then accesses B&apos;s member.
Condition (b) is the culprit, and exists in other places in the code base. Ian identified some of them along the discussion. A crash needs all of (a), (b), (c) and this place is the only one we discovered so far. I&apos;d think we just fix this crash now while looking for long term solution to address (b) in general. The step towards general solution, which I am looking into, is finding all instances of (b) so we have a better understanding of the scope of the problem. 

Re: (1), (3)
So alloca is not portable either. (3) works as I verified it although future version of compiler might still optimize the reference away. Using MSVC macro works with all versions of VC compiler but it is platform dependent. (3) seems to be the best for now. New patch attached.  </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20031</commentid>
    <comment_count>33</comment_count>
      <attachid>13519</attachid>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-03-07 11:36:52 -0800</bug_when>
    <thetext>Comment on attachment 13519
Fix

r=me (although the ChangeLog comment is wrong now in mentioning alloca).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>19869</commentid>
    <comment_count>34</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-03-07 17:57:55 -0800</bug_when>
    <thetext>Landed in r20043.  Can you please ensure that your ChangeLog entries use spaces rather than tabs for indentation in future.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16424</commentid>
    <comment_count>35</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-03-30 15:45:20 -0700</bug_when>
    <thetext>(In reply to comment #27)
&gt; Returning a value instead of a pointer into the object seems fine. We should
&gt; probably document that as a rule.
&gt; 

Saw this bug in another platform using a stocked version of webkit. The compiler in use is GCC for Linux. Exact the same place. I missed the case in comment #18 when a member field address of &apos;this&apos; is passed to a callee. &apos;This&apos; pointer is optimized away and &apos;this&apos; object is considered as dead by GC. GC is triggered in the callee.

Solution I mentioned in comment #18 won&apos;t fix this problem.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>12864</attachid>
            <date>2007-02-01 16:53:43 -0800</date>
            <delta_ts>2007-02-05 14:16:38 -0800</delta_ts>
            <desc>trace pointers into bodies</desc>
            <filename>collector.cpp.diff</filename>
            <type>text/plain</type>
            <size>2147</size>
            <attacher name="Feng Qian">ian.eng.webkit</attacher>
            
              <data encoding="base64">MTM4LDEzOWMxMzgsMTQ1DQo8ICAgICB2b2lkICpuZXdDZWxsID0gZmFzdE1hbGxvYyhzKTsNCjwg
ICAgIGhlYXAub3ZlcnNpemVDZWxsc1t1c2VkT3ZlcnNpemVDZWxsc10gPSBzdGF0aWNfY2FzdDxD
b2xsZWN0b3JDZWxsICo+KG5ld0NlbGwpOw0KLS0tDQo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iAgICAgICAgIHNpemVfdCBsZW5ndGggPSAqKHJlaW50ZXJwcmV0X2Nhc3Q8
c2l6ZV90Kj4oY2VsbFN0YXJ0KSAtIDEpOw0KPiAgICAgICAgIGNoYXIqIGNlbGxFbmQgPSBjZWxs
U3RhcnQgKyBsZW5ndGg7DQo+ICAgICAgICAgaWYgKGNlbGxTdGFydCA8PSB4ICYmIHggPCBjZWxs
RW5kKSB7DQo+ICAgICAgICAgICB4ID0gY2VsbFN0YXJ0Ow0KMjg3YTMwNCwzMDUNCj4gICAgICAg
ICB9DQo+ICAgICAgIH0NCjU3N2M1OTUsNTk3DQo8ICAgICAgIGZhc3RGcmVlKGltcCk7DQotLS0N
Cj4gICAgICAgLy8gYWRqdXN0IHBvaW50ZXIgdG8gdGhlIGJlZ2lubmluZyBvZiB0aGUgcmF3IG1l
bW9yeQ0KPiAgICAgICBzaXplX3QqIHJhd01lbSA9IHJlaW50ZXJwcmV0X2Nhc3Q8c2l6ZV90Kj4o
aW1wKSAtIDE7DQo+ICAgICAgIGZhc3RGcmVlKHJhd01lbSk7DQo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>12947</attachid>
            <date>2007-02-05 14:16:38 -0800</date>
            <delta_ts>2007-02-09 22:46:12 -0800</delta_ts>
            <desc>a patch for preformance test</desc>
            <filename>Bug12535Patch.txt</filename>
            <type>text/plain</type>
            <size>3441</size>
            <attacher name="Feng Qian">ian.eng.webkit</attacher>
            
              <data encoding="base64">SW5kZXg6IEphdmFTY3JpcHRDb3JlL2tqcy9jb2xsZWN0b3IuY3BwCj09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIEph
dmFTY3JpcHRDb3JlL2tqcy9jb2xsZWN0b3IuY3BwCShyZXZpc2lvbiAxOTQwNykKKysrIEphdmFT
Y3JpcHRDb3JlL2tqcy9jb2xsZWN0b3IuY3BwCSh3b3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</data>
<flag name="review"
          id="5020"
          type_id="1"
          status="-"
          setter="mjs"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>13507</attachid>
            <date>2007-03-06 22:38:40 -0800</date>
            <delta_ts>2007-03-07 00:36:31 -0800</delta_ts>
            <desc>Proposing fix</desc>
            <filename>12535_patch.txt</filename>
            <type>text/plain</type>
            <size>1410</size>
            <attacher name="Huan Ren">huanr</attacher>
            
              <data encoding="base64">SW5kZXg6IEphdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBKYXZhU2NyaXB0
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDIwMDA2KQorKysgSmF2YVNjcmlwdENvcmUvQ2hhbmdl
TG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTMgQEAKKzIwMDctMDMtMDYgIEFucm9uZyBI
dSAgPGh1YW5yQHlhaG9vLmNvbT4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMh
KS4KKworCUJ1ZyAxMjUzNTogU3RhY2stb3B0aW1pemluZyBjb21waWxlcnMgY2FuIHRyaWNrIEdD
IGludG8gZnJlZWluZyBpbi11c2Ugb2JqZWN0cworCUZpeDogVXNlIGFsbG9jYSBhbmQgZXhwbGlj
aXRseSBwdXQgdGhlIG9iamVjdCByZWZlcmVuY2Ugb250byB0aGUgc3RhY2suCisKKyAgICAgICAg
KiBranMvaW50ZXJuYWwuY3BwOgorICAgICAgICAoS0pTOjpTdHJpbmdJbXA6OnRvT2JqZWN0KToK
KwogMjAwNy0wMy0wNiAgR2VvZmZyZXkgR2FyZW4gIDxnZ2FyZW5AYXBwbGUuY29tPgogCiAgICAg
ICAgIFJldmlld2VkIGJ5IE1hY2llaiBTdGFjaG93aWFrLgpJbmRleDogSmF2YVNjcmlwdENvcm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_id="1"
          status="-"
          setter="mjs"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>13519</attachid>
            <date>2007-03-07 11:33:41 -0800</date>
            <delta_ts>2007-03-07 11:36:52 -0800</delta_ts>
            <desc>Fix</desc>
            <filename>12535_patch.txt</filename>
            <type>text/plain</type>
            <size>1353</size>
            <attacher name="Huan Ren">huanr</attacher>
            
              <data encoding="base64">SW5kZXg6IEphdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBKYXZhU2NyaXB0
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDIwMDA2KQorKysgSmF2YVNjcmlwdENvcmUvQ2hhbmdl
TG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTMgQEAKKzIwMDctMDMtMDYgIEFucm9uZyBI
dSAgPGh1YW5yQHlhaG9vLmNvbT4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMh
KS4KKworCUJ1ZyAxMjUzNTogU3RhY2stb3B0aW1pemluZyBjb21waWxlcnMgY2FuIHRyaWNrIEdD
IGludG8gZnJlZWluZyBpbi11c2Ugb2JqZWN0cworCUZpeDogVXNlIGFsbG9jYSBhbmQgZXhwbGlj
aXRseSBwdXQgdGhlIG9iamVjdCByZWZlcmVuY2Ugb250byB0aGUgc3RhY2suCisKKyAgICAgICAg
KiBranMvaW50ZXJuYWwuY3BwOgorICAgICAgICAoS0pTOjpTdHJpbmdJbXA6OnRvT2JqZWN0KToK
KwogMjAwNy0wMy0wNiAgR2VvZmZyZXkgR2FyZW4gIDxnZ2FyZW5AYXBwbGUuY29tPgogCiAgICAg
ICAgIFJldmlld2VkIGJ5IE1hY2llaiBTdGFjaG93aWFrLgpJbmRleDogSmF2YVNjcmlwdENvcmUv
a2pzL2ludGVybmFsLmNwcAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBKYXZhU2NyaXB0Q29yZS9ranMvaW50ZXJu
YWwuY3BwCShyZXZpc2lvbiAxOTk5MikKKysrIEphdmFTY3JpcHRDb3JlL2tqcy9pbnRlcm5hbC5j
cHAJKHdvcmtpbmcgY29weSkKQEAgLTc4LDcgKzc4LDExIEBAIFVTdHJpbmcgU3RyaW5nSW1wOjp0
b1N0cmluZyhFeGVjU3RhdGUgKikKIAogSlNPYmplY3QgKlN0cmluZ0ltcDo6dG9PYmplY3QoRXhl
Y1N0YXRlICpleGVjKSBjb25zdAogewotICAgIHJldHVybiBuZXcgU3RyaW5nSW5zdGFuY2UoZXhl
Yy0+bGV4aWNhbEludGVycHJldGVyKCktPmJ1aWx0aW5TdHJpbmdQcm90b3R5cGUoKSwgdmFsKTsK
KyAgICAvLyBQdXQgdGhlIHJlZmVyZW5jZSBvbnRvIHRoZSBzdGFjayBzbyBpdCBpcyBub3Qgc3Vi
amVjdCB0byBnYXJiYWdlIGNvbGxlY3Rpb24uCisgICAgLy8gU2VlIHdlYmtpdCBidWcgMTI1MzUu
CisgICAgVVN0cmluZyB2YWxDb3B5ID0gdmFsOworCisgICAgcmV0dXJuIG5ldyBTdHJpbmdJbnN0
YW5jZShleGVjLT5sZXhpY2FsSW50ZXJwcmV0ZXIoKS0+YnVpbHRpblN0cmluZ1Byb3RvdHlwZSgp
LCB2YWxDb3B5KTsKIH0KIAogLy8gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tIE51bWJl
ckltcCAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0K
</data>
<flag name="review"
          id="5347"
          type_id="1"
          status="+"
          setter="mjs"
    />
          </attachment>
      

    </bug>

</bugzilla>