Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Would this crash your browser?
- Hamish752
-
1000+ posts
Would this crash your browser?
You could've just done, something simpler like this, without all those 9s 

for(var i = 1; i < 1; i++) { console.log(i); };
- liam48D
-
1000+ posts
Would this crash your browser?
Keep in mind nothing will generally happen because the loop is already finished - literally, it's “while i (which is initially set to 999999999 to the power of 999999999) is less than -9999999999999999999, decrease i by one.” Because the initial i is not less than -9999999999999999999, nothing ever happens in the loop. If anything crashes the browser it'll be the fact that you're computing such a big number! (999999999 ** 999999999)
- Hamish752
-
1000+ posts
Would this crash your browser?
Keep in mind nothing will generally happen because the loop is already finished - literally, it's “while i (which is initially set to 999999999 to the power of 999999999) is less than -9999999999999999999, decrease i by one.” Because the initial i is not less than -9999999999999999999, nothing ever happens in the loop. If anything crashes the browser it'll be the fact that you're computing such a big number! (999999999 ** 999999999)
for (var i = 999999999 ** 999999999; i > -9999999999999999999; i--){ console.log(i + 9999*9999); };
Last edited by Hamish752 (Dec. 27, 2015 12:06:39)
- comp09
-
1000+ posts
Would this crash your browser?
“**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
- Dylan5797
-
1000+ posts
Would this crash your browser?
yay math. “**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
- Dylan5797
-
1000+ posts
Would this crash your browser?
What about just this:Keep in mind nothing will generally happen because the loop is already finished - literally, it's “while i (which is initially set to 999999999 to the power of 999999999) is less than -9999999999999999999, decrease i by one.” Because the initial i is not less than -9999999999999999999, nothing ever happens in the loop. If anything crashes the browser it'll be the fact that you're computing such a big number! (999999999 ** 999999999)would work better…for (var i = 999999999 ** 999999999; i > -9999999999999999999; i--){ console.log(i + 9999*9999); };
for (var i = 1; i === null; i++){ console.log(i*9999*9999); };
Last edited by Dylan5797 (Dec. 27, 2015 14:50:59)
- liam48D
-
1000+ posts
Would this crash your browser?
Dude, ES6! “**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”

- comp09
-
1000+ posts
Would this crash your browser?
???Dude, ES6! “**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”

- liam48D
-
1000+ posts
Would this crash your browser?
Only supported by Nightly at the moment, I think.???Dude, ES6! “**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
- TheMonsterOfTheDeep
-
1000+ posts
Would this crash your browser?
The following crashed my Chrome browser:
And I can make it worse:
This is, of course, essentially the same as the for loop with no exit condition. :package:
while(true) { console.log("true!"); } //while true doesn't like you! :D
var killBrowser = function() { while(true) { setInterval(killBrowser, 10); } } killBrowser();
Last edited by TheMonsterOfTheDeep (Dec. 27, 2015 17:56:23)
- Hamish752
-
1000+ posts
Would this crash your browser?
What about just this…What about just this:Keep in mind nothing will generally happen because the loop is already finished - literally, it's “while i (which is initially set to 999999999 to the power of 999999999) is less than -9999999999999999999, decrease i by one.” Because the initial i is not less than -9999999999999999999, nothing ever happens in the loop. If anything crashes the browser it'll be the fact that you're computing such a big number! (999999999 ** 999999999)would work better…for (var i = 999999999 ** 999999999; i > -9999999999999999999; i--){ console.log(i + 9999*9999); };for (var i = 1; i === null; i++){ console.log(i*9999*9999); };
for (var i = 1;var i <1;i++) { console.log(i); };
- DrKat123
-
1000+ posts
Would this crash your browser?
Ooops “**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”

A simple yet deadly for loop, tried that and crashed my PC, wait wat You could've just done, something simpler like this, without all those 9sfor(var i = 1; i < 1; i++) { console.log(i); };
Only supported by Nightly at the moment, I think.???Dude, ES6! “**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
Yeah, noticed that would happen
Wow, while true really doesn't like you. The following crashed my Chrome browser:And I can make it worse:while(true) { console.log("true!"); } //while true doesn't like you! :DThis is, of course, essentially the same as the for loop with no exit condition. :package:var killBrowser = function() { while(true) { setInterval(killBrowser, 10); } } killBrowser();
Btw tried my modified script on the browser's console; and it only slows down my computer to a crash

- TheMonsterOfTheDeep
-
1000+ posts
Would this crash your browser?
Well, I mean, my scripts don't actually *crash* the browser, they just make it incredibly unresponsive. :package:
- Srevilo
-
92 posts
Would this crash your browser?
It doesn't crash my browser but doesn't print anything to the console. Tested on Chrome 45.
- Hamish752
-
1000+ posts
Would this crash your browser?
Simple scripts, are the best scriptsA simple yet deadly for loop, tried that and crashed my PC, wait wat You could've just done, something simpler like this, without all those 9sfor(var i = 1; i < 1; i++) { console.log(i); };

Last edited by Hamish752 (Dec. 28, 2015 08:53:39)
- DrKat123
-
1000+ posts
Would this crash your browser?
I ♥ Mininalistic and simple scrpts XDSimple scripts, are the best scriptsA simple yet deadly for loop, tried that and crashed my PC, wait wat You could've just done, something simpler like this, without all those 9sfor(var i = 1; i < 1; i++) { console.log(i); };
What if you run this
var y = 100; while (y > 0){ //do pointless stuff or other things here //wait wat no y-- };
- Jonathan50
-
1000+ posts
Would this crash your browser?
/* * Copyright (C) Jonathan50 * All rights reserved. * * You may do what you like with this, so long as you * do not remove the first two lines (copyright) and * do not use it to harm or disadvantage other * people without permission by intentionally * crashing their computer by running this script. * This thing has comes with no warranty (unless * it has to because of the law) * Jonathan50 does not accept any responsibility for anything * you do with this. (unless he has to because of the law) * Use at your own risk. * * Lol I wrote a license thingy. */ (function f(){while(1){w=window.open('about:blank','','height=360,width=480');w.document.open();w.document.write('<!DOCTYPE html><html><head><script>('+f.toString()+')();</'+'script></head><body><h1>Ok</h1><h2>Crashy crashes</h2></body></html>');w.document.close();}})();
Warning: I wouldn't recommend running this, especially if you have unsaved stuff open. It has the potential to crash your browser or even your computer.
now I'm going to close everything and run it…
Edit: not working for some reason. Working on it…
Edit 2: something's weird…
Edit 3: oh it's the </script> in the string literal
fixed!!
Edit 4: done!
Edit 5: open in seperate windows
Edit 6: enlarge windows
Firefox has some nice protective mechanisms and there is a limit on opening tabs
Should kill IE or perhaps even Edge, Safari and Chrome easily!
Edit 7: on Firefox if you want to disable it in about:config go to dom.popup_maximum
Last edited by Jonathan50 (Dec. 29, 2015 22:29:15)
- thisandagain
-
500+ posts
Would this crash your browser?
The following crashed my Chrome browser:And I can make it worse:while(true) { console.log("true!"); } //while true doesn't like you! :DThis is, of course, essentially the same as the for loop with no exit condition. :package:var killBrowser = function() { while(true) { setInterval(killBrowser, 10); } } killBrowser();
That is what I would recommend as well. The issue you are describing / exploiting is called the “Halting Problem” in CS:
https://en.wikipedia.org/wiki/Halting_problem
- Jonathan50
-
1000+ posts
Would this crash your browser?
Wow. My computer frozed but I managed to switch to a virtual TTY and stop it with// -snip-
Warning: I wouldn't recommend running this, especially if you have unsaved stuff open. It has the potential to crash your browser or even your computer.
now I'm going to close everything and run it…
Edit: not working for some reason. Working on it…
Edit 2: something's weird…
Edit 3: oh it's the </script> in the string literal
fixed!!
Edit 4: done!
Edit 5: open in seperate windows
Edit 6: enlarge windows
Firefox has some nice protective mechanisms and there is a limit on opening tabs
Should kill IE or perhaps even Edge, Safari and Chrome easily!
Edit 7: on Firefox if you want to disable it in about:config go to dom.popup_maximum
while true; do killall icecat; done
Edit: I stopped it by reopening it and sending it SIGKILL. Firefox's “feature” that if it abruptly terminated it can't restore your browsing session is actually useful

Last edited by Jonathan50 (Dec. 29, 2015 22:43:53)
- Discussion Forums
- » Advanced Topics
-
» Would this crash your browser?