<?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>117801</bug_id>
          
          <creation_ts>2013-06-19 10:30:08 -0700</creation_ts>
          <short_desc>JSC: StackPolicy should use a more reasonable requiredStack value</short_desc>
          <delta_ts>2013-06-21 09:37:10 -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>528+ (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>
          
          <blocked>116661</blocked>
    
    <blocked>117862</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Mark Lam">mark.lam</reporter>
          <assigned_to name="Mark Lam">mark.lam</assigned_to>
          <cc>bdakin</cc>
    
    <cc>bfulgham</cc>
    
    <cc>commit-queue</cc>
    
    <cc>ggaren</cc>
    
    <cc>paroga</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>901837</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-06-19 10:30:08 -0700</bug_when>
    <thetext>This issue was discovered while trying to apply the patch from https://bugs.webkit.org/show_bug.cgi?id=116661.

The testsapi tests fails with an ASSERTION failure if the available stack discovered by StackBounds is only 242K.  There are 2 issues found so far:

1. The StackPolicy (in Interpreter.cpp) is asserting that the stack should be greater than 256K.  On Windows, the entire stack size (before we discount the guard page) is 256K.  Hence, this assertion will always fail on Windows if the StackBounds is computed correctly.

2. If we loosen the restriction in issue (1), we can run jsc far enough until we hit another assertion failure in testapi.  The root cause for this assertion failure is not yet known.

The 256K stack size requirement in StackPolicy was chosen based on heuristics.  However, it seems improbable that we aren&apos;t able to run testapi on 242K of stack.  Will need to investigate the root cause of issue (2).  We also need to reconsider if the 256K requirement in issue (1) is appropriate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>901842</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-06-19 10:33:50 -0700</bug_when>
    <thetext>FYI, if I artificially restrict the stack size to 242K on OSX, I get the same assertion failures.  Will continue debugging this issue on OSX.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>901894</commentid>
    <comment_count>2</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2013-06-19 12:32:09 -0700</bug_when>
    <thetext>&gt; We also need to reconsider if the 256K requirement in issue (1) is appropriate.

It isn&apos;t.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902165</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-06-20 08:46:51 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; FYI, if I artificially restrict the stack size to 242K on OSX, I get the same assertion failures.  Will continue debugging this issue on OSX.

Issue (2) is not an issue.  I encountered that assertion failure because in the test I ran, I changed the stack size to 242K and the StackPolicy&apos;s requiredStack size to 242K as well.  Hence, right off the start based on these values, we&apos;re out of stack space.  The test is invalid.  Hence, issue (2) is not an issue.

What remains is issue (1) i.e. we need to pick a more sane value for the StackPolicy&apos;s requiredStack.  I&apos;ve confirmed that on Windows which has a ~256K stack, changing the requiredStack to 100K (just for testing … not saying that this is the appropriate value to use), the run-javascriptcore-tests ran to completion with 0 errors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902344</commentid>
    <comment_count>4</comment_count>
      <attachid>205125</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-06-20 15:10:24 -0700</bug_when>
    <thetext>Created attachment 205125
the patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902345</commentid>
    <comment_count>5</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-06-20 15:12:21 -0700</bug_when>
    <thetext>Attachment 205125 did not pass style-queue:

Failed to run &quot;[&apos;Tools/Scripts/check-webkit-style&apos;, &apos;--diff-files&apos;, u&apos;Source/JavaScriptCore/ChangeLog&apos;, u&apos;Source/JavaScriptCore/interpreter/Interpreter.cpp&apos;]&quot; exit_code: 1
Source/JavaScriptCore/ChangeLog:27:  Line contains tab character.  [whitespace/tab] [5]
Source/JavaScriptCore/ChangeLog:30:  Line contains tab character.  [whitespace/tab] [5]
Source/JavaScriptCore/ChangeLog:31:  Line contains tab character.  [whitespace/tab] [5]
Total errors found: 3 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902346</commentid>
    <comment_count>6</comment_count>
      <attachid>205125</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2013-06-20 15:14:50 -0700</bug_when>
    <thetext>Comment on attachment 205125
the patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902349</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-06-20 15:18:32 -0700</bug_when>
    <thetext>Landed in r151808: &lt;http://trac.webkit.org/changeset/151808&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902370</commentid>
    <comment_count>8</comment_count>
    <who name="Beth Dakin">bdakin</who>
    <bug_when>2013-06-20 17:22:20 -0700</bug_when>
    <thetext>This change caused fast/xmlhttprequest/xmlhttprequest-recursive-sync-event.html to start failing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902421</commentid>
    <comment_count>9</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2013-06-20 20:55:28 -0700</bug_when>
    <thetext>--- /Volumes/Data/slave/mountainlion-release-tests-wk2/build/layout-test-results/fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt
+++ /Volumes/Data/slave/mountainlion-release-tests-wk2/build/layout-test-results/fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-actual.txt
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: RangeError: Maximum call stack size exceeded.
-CONSOLE MESSAGE: RangeError: Maximum call stack size exceeded.
+CONSOLE MESSAGE: 
+CONSOLE MESSAGE: 
 This tests that having infinite recursion in XMLHttpRequest event handler does not crash. 
 PASS


Why are we not seeing any error messages now?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902422</commentid>
    <comment_count>10</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2013-06-20 20:57:31 -0700</bug_when>
    <thetext>It makes sense if those console message stopped appearing but they are still there just without an useful error message.

Does anyone know why we have two empty console messages?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902424</commentid>
    <comment_count>11</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2013-06-20 20:59:17 -0700</bug_when>
    <thetext>Filed https://bugs.webkit.org/show_bug.cgi?id=117801 to track the tea failure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902581</commentid>
    <comment_count>12</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-06-21 09:22:57 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; -CONSOLE MESSAGE: RangeError: Maximum call stack size exceeded.
&gt; -CONSOLE MESSAGE: RangeError: Maximum call stack size exceeded.
&gt; +CONSOLE MESSAGE: 
&gt; +CONSOLE MESSAGE: 
&gt; 
&gt; Why are we not seeing any error messages now?

The reason is because the interpreter StackPolicy is not used universally in the VM.  There are parts of the VM that does stack checks based on the default StackBound capacity requirement.  The default StackBound capacity requirement turned out to be larger than the interpreter StackPolicy requirements.  So, when handling the StackOverflowError, we were able to re-enter the interpreter (which we need to do to create the message string), but we soon fail in StringRecursionCheck which uses the default StackBound check.

This causes the String operation to be aborted.  The result is the blank message.

The fix is to either increase the interpreter StackPolicy values to match the default StackBounds values, or reduce the StackBounds values to match the interpreter StackPolicy values.  For now, to be conservative, I&apos;ll increase the interpreter StackPolicy values.

The fix will be tracked in https://bugs.webkit.org/show_bug.cgi?id=117862.

&gt; Does anyone know why we have two empty console messages?

I suspect this is an artifact of the test using even handlers.  If an event was already queued while we&apos;re handling the StackOverflow, WebCore will invoke another event listener and get a 2nd stack overflow.

The only thing that changed after this patch is that we&apos;re not able to create the string for the error message.  We were getting 2 StackOverflowErrors before, and we&apos;re still getting 2 now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902587</commentid>
    <comment_count>13</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2013-06-21 09:37:10 -0700</bug_when>
    <thetext>&gt; For now, to be conservative, I&apos;ll increase the interpreter StackPolicy values.

Why do we have two different ways to check for stack overflow at all. This is way over-engineered. The whole point of the patch that introduced the StackPolicy class was to get all of our code onto a single, shared mechanism for checking for stack overflow.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>205125</attachid>
            <date>2013-06-20 15:10:24 -0700</date>
            <delta_ts>2013-06-20 15:14:50 -0700</delta_ts>
            <desc>the patch</desc>
            <filename>bug-117801.patch</filename>
            <type>text/plain</type>
            <size>3980</size>
            <attacher name="Mark Lam">mark.lam</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291
cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkocmV2aXNpb24gMTUxODAxKQorKysgU291cmNl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B0cmFjZSwgYW5kIG5vdCBydW4gYW55IGFyYml0cmFy
eSBKUyBjb2RlLiBBcyBzdWNoLCBpdCBpcyBzYWZlIHRvCisgICAgICAgIGFsbG93IHJlLWVudHJ5
IGludG8gdGhlIGludGVycHJldGVyIHdpdGggb25seSAyeCB0aGUgbWVhc3VyZWQgdXNhZ2UgaW4K
KyAgICAgICAgdGhpcyBjYXNlLgorCisgICAgICAgICogaW50ZXJwcmV0ZXIvSW50ZXJwcmV0ZXIu
Y3BwOgorICAgICAgICAoSlNDOjpJbnRlcnByZXRlcjo6U3RhY2tQb2xpY3k6OlN0YWNrUG9saWN5
KToKKwogMjAxMy0wNi0yMCAgTWlraGFpbCBQb3pkbnlha292ICA8bWlraGFpbC5wb3pkbnlha292
QGludGVsLmNvbT4KIAogICAgICAgICBIYXNoU2V0OiByZXZlcnNlIHRoZSBvcmRlciBvZiB0aGUg
dGVtcGxhdGUgYXJndW1lbnRzIGF0IGFsdGVybmF0ZSAnZmluZCcsICdjb250YWlucycgYW5kICdh
ZGQnIG1ldGhvZHMKSW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9pbnRlcnByZXRlci9JbnRl
cnByZXRlci5jcHAKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291cmNlL0phdmFTY3JpcHRDb3JlL2ludGVycHJl
dGVyL0ludGVycHJldGVyLmNwcAkocmV2aXNpb24gMTUxNzg3KQorKysgU291cmNlL0phdmFTY3Jp
cHRDb3JlL2ludGVycHJldGVyL0ludGVycHJldGVyLmNwcAkod29ya2luZyBjb3B5KQpAQCAtMTI2
LDEyICsxMjYsMTIgQEAgSW50ZXJwcmV0ZXI6OlN0YWNrUG9saWN5OjpTdGFja1BvbGljeShJbgog
ICAgIC8vCiAgICAgLy8gVGhlc2Ugc2l6ZXMgd2VyZSBkZXJpdmVkIGZyb20gdGhlIHN0YWNrIHVz
YWdlIG9mIGEgbnVtYmVyIG9mIHNpdGVzIHdoZW4KICAgICAvLyBsYXlvdXQgb2NjdXJzIHdoZW4g
d2UndmUgYWxyZWFkeSBjb25zdW1lZCBtb3N0IG9mIHRoZSBDIHN0YWNrLgotICAgIGNvbnN0IHNp
emVfdCByZXF1aXJlZFN0YWNrID0gMjU2ICogS0I7Ci0gICAgY29uc3Qgc2l6ZV90IGVycm9yTW9k
ZVJlcXVpcmVkU3RhY2sgPSA2NCAqIEtCOworICAgIGNvbnN0IHNpemVfdCByZXF1aXJlZFN0YWNr
ID0gMzIgKiBLQjsKKyAgICBjb25zdCBzaXplX3QgZXJyb3JNb2RlUmVxdWlyZWRTdGFjayA9IDE2
ICogS0I7CiAKICAgICBzaXplX3QgcmVxdWlyZWRDYXBhY2l0eSA9IG1faW50ZXJwcmV0ZXIubV9l
cnJvckhhbmRsaW5nTW9kZVJlZW50cnkgPyBlcnJvck1vZGVSZXF1aXJlZFN0YWNrIDogcmVxdWly
ZWRTdGFjazsKIAotICAgIFJFTEVBU0VfQVNTRVJUKHNpemUgPiByZXF1aXJlZENhcGFjaXR5KTsK
KyAgICBSRUxFQVNFX0FTU0VSVChzaXplID49IHJlcXVpcmVkQ2FwYWNpdHkpOwogICAgIAogICAg
IG1fcmVxdWlyZWRDYXBhY2l0eSA9IHJlcXVpcmVkQ2FwYWNpdHk7ICAgIAogfQo=
</data>
<flag name="review"
          id="226594"
          type_id="1"
          status="+"
          setter="ggaren"
    />
          </attachment>
      

    </bug>

</bugzilla>