Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart2js generates ">>> 0" that fail in safari after ~400 executions #16011

Closed
DartBot opened this issue Jan 10, 2014 · 4 comments
Closed

Dart2js generates ">>> 0" that fail in safari after ~400 executions #16011

DartBot opened this issue Jan 10, 2014 · 4 comments
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@DartBot
Copy link

DartBot commented Jan 10, 2014

This issue was originally filed by xavier.ha...@gmail.com


What steps will reproduce the problem?
Run this dummy code on Safari iOS 6 or 7

import 'dart:html';
main() {
  List<bool> pattern = [true, false];
  int index = 0;
  
  int animate() {
    for(int i = 0; i < 1; i++) {
      int patternIndex = index.abs();
      toggle(pattern[patternIndex]);
    }
  }
  
  int i = 0;
  try {
    for(; i < 1000; i++) {
     animate();
    }
  }catch(e) {
    window.alert('$e: $i');
  }
}
toggle(bool on) { }

What is the expected output? What do you see instead?
It runs fine on all browser except iOS Safari.
It shows an alert with "RangeError: value 0: 384"

The reason is that dart2js generates code like this:
if (patternIndex >>> 0 !== patternIndex || patternIndex >= 2)
  return H.ioore(t2, patternIndex);

I had a similar issue previously on iOS when doing a >> 0: after a few hundreds executions, it starts to fail.

It clearly looks like a bug in the javascript engine of Safari, but I think dart2js could do something about it and never emmit '>> 0' code.

What version of the product are you using? On what operating system?
Editor: 1.1.0.dev_05_00 (2013-12-20)

Please provide any additional information below.

@iposva-google
Copy link
Contributor

Added Area-Dart2JS, Triaged labels.

@floitschG
Copy link
Contributor

That's bad :(
Do you know if the Safari developers are aware of this issue?

The shifts are one of the most efficient ways to determine that the value is an integer in the positive 32-bit range, so we would like to avoid changing our pattern.

I will leave this bug open and talk to others if they can reproduce, and if there are better solutions.

@DartBot
Copy link
Author

DartBot commented Jan 13, 2014

This comment was originally written by xavier.ha...@gmail.com


Thank you for your answer.
I don't know if there is an open issue in the Safari bug tracker but there are peoples with similar issue on iPad here:
http://stackoverflow.com/questions/19357775/something-wrong-with-javascript-unsigned-shift-operator-on-ipad

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@floitschG
Copy link
Contributor

According to the linked stackoverflow this issues seems to have been fixed.
Closing as obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants