Bug 40355 - Exception loading Google Wave in Safari 5
Summary: Exception loading Google Wave in Safari 5
Status: RESOLVED DUPLICATE of bug 40367
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P1 Normal
Assignee: Nobody
URL:
Keywords: GoogleBug, InRadar
Depends on:
Blocks:
 
Reported: 2010-06-09 00:16 PDT by noel gordon
Modified: 2010-06-11 09:42 PDT (History)
7 users (show)

See Also:


Attachments
Test Case (579 bytes, text/html)
2010-06-09 01:09 PDT, noel gordon
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description noel gordon 2010-06-09 00:16:10 PDT
Load Google Wave in Safari 5 (win32, and/or mac/osx 10.5), the
javascript console reports:

   RangeError: Maximum call stack size exceeded.

and Google Wave stops working. Test results/reduction attached

  OSX Firefox 3.6    OK  
  OSX Safari 4.0.4   OK
  OSX Chrome 5.0.375 OK
  OSX Safari 5.0     FAIL
Comment 1 noel gordon 2010-06-09 01:09:54 PDT
Created attachment 58221 [details]
Test Case
Comment 2 Gavin Barraclough 2010-06-09 13:43:38 PDT
<rdar://problem/8076614>
Comment 3 Steve Dunham 2010-06-09 14:34:37 PDT
This issue seems to only occur when Safari 5 is run in 32-bit mode.
Comment 4 Steve Dunham 2010-06-09 16:04:55 PDT
If you replace:

    tmp = (tmp >> 1);

with

   var tmp2 = (tmp >> 1);
   tmp = tmp2;

the testcase passes.

If you instrument the original testcase with print statements, tmp.toString() is "3" before the shift operation and "3.0000000000000004" afterwards.
Comment 5 Joel Webber 2010-06-09 16:36:25 PDT
The following is a related, but slightly narrower form of the bug:

function merge(d,e,f) {
  var h,i,j,k;
  h = e - d;
  if (h < 3) {
    return
  }
  j = d + f;
  i = e + f;
  k = j + (i - j >> 1);
  merge(j,k,-f);
  merge(k,i,-f);
}
merge(0, 5, 0);

From the console, when you set a breakpoint in merge(2, 5, 0):
> i
   5
> j
   2
> (i - j)
   3
> ((i - j) >> 1)
   1
> j + ((i - j) >> 1)
   5 <= WTF?!
Comment 6 Steve Dunham 2010-06-11 08:56:41 PDT
Further reduced test case:

function test() {
    var off = -0;
    var tmp = 5 + off;
    var tmp2 = (tmp >> 1);
    tmp = tmp >> 1;
    if (tmp != tmp2)
        document.getElementById("result").innerHTML = "fail "+tmp+" != "+tmp2;
    else
        document.getElementById("result").innerHTML = "pass";
}

Gives:
  fail 5.000000000000002 != 2

It looks like adding "-0" to an integer results in a value that will right shift correctly in some contexts but not in others.  (Note that tmp2 holds the correct value, but tmp does not.)
Comment 7 Oliver Hunt 2010-06-11 09:42:56 PDT

*** This bug has been marked as a duplicate of bug 40367 ***