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

Calling math.random() freezes IE and node.js #824

Closed
ghost opened this issue Apr 5, 2017 · 5 comments
Closed

Calling math.random() freezes IE and node.js #824

ghost opened this issue Apr 5, 2017 · 5 comments
Labels

Comments

@ghost
Copy link

ghost commented Apr 5, 2017

calling this method causes the IE 11.0 hangs:

math.ceil(math.random() * 10000000000000);

@FSMaxB
Copy link
Collaborator

FSMaxB commented Apr 5, 2017

This not only happens with IE 11.0. I just confirmed it with nodejs 7.7.3.

Interestingly math.eval('ceil(random() * 10000000000000)') works fine

This can be reproduced by just typing math.random or math.randomInt and hitting enter. Maybe related to lazyloading, not sure though.

@FSMaxB FSMaxB added the bug label Apr 5, 2017
@ghost
Copy link
Author

ghost commented Apr 5, 2017

Oh! Interseting bug :)
also your workaround doesn't worked for me! I replaced it with javascript pure lib (Math class)

@FSMaxB
Copy link
Collaborator

FSMaxB commented Apr 5, 2017

Yes, math.eval does in fact not work. It works with bin/cli.js though, strange.

@josdejong @morsecodist This happened somewhere between 3d46e21 and 0502921 where the RNG was replaced.

@josdejong josdejong changed the title IE 11.0 hangs on math.ceil math.random() freezes IE and node.js Apr 17, 2017
@josdejong josdejong changed the title math.random() freezes IE and node.js Calling math.random() freezes IE and node.js Apr 17, 2017
@josdejong
Copy link
Owner

I found the underlying cause. Calling seed-random caused an infinite loop, because it was being called inside an object getter of a globally defined object (math.random), whilst seed-random uses all globally defined objects to generate a local entropy.

See ForbesLindesay/seed-random#6 for more details.

@josdejong
Copy link
Owner

Should be fixed in v3.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants