Discuss Scratch

DrKat123
Scratcher
1000+ posts
Hamish752
Scratcher
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
Scratcher
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
Scratcher
1000+ posts

Would this crash your browser?

liam48D wrote:

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);
};
would work better…

Last edited by Hamish752 (Dec. 27, 2015 12:06:39)

comp09
Scratcher
1000+ posts

Would this crash your browser?

“**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
Dylan5797
Scratcher
1000+ posts

Would this crash your browser?

comp09 wrote:

“**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
yay math.
Dylan5797
Scratcher
1000+ posts

Would this crash your browser?

Hamish752 wrote:

liam48D wrote:

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);
};
would work better…
What about just this:
for (var i = 1; i === null; i++){
console.log(i*9999*9999);
};

Last edited by Dylan5797 (Dec. 27, 2015 14:50:59)

liam48D
Scratcher
1000+ posts

Would this crash your browser?

comp09 wrote:

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

Would this crash your browser?

liam48D wrote:

comp09 wrote:

“**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
Dude, ES6!
???
liam48D
Scratcher
1000+ posts

Would this crash your browser?

comp09 wrote:

liam48D wrote:

comp09 wrote:

“**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
Dude, ES6!
???
Only supported by Nightly at the moment, I think.
TheMonsterOfTheDeep
Scratcher
1000+ posts

Would this crash your browser?

The following crashed my Chrome browser:
while(true) { console.log("true!"); } //while true doesn't like you! :D
And I can make it worse:
var killBrowser = function() {
    while(true) { setInterval(killBrowser, 10); }
}
killBrowser();
This is, of course, essentially the same as the for loop with no exit condition. :package:

Last edited by TheMonsterOfTheDeep (Dec. 27, 2015 17:56:23)

Hamish752
Scratcher
1000+ posts

Would this crash your browser?

Dylan5797 wrote:

Hamish752 wrote:

liam48D wrote:

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);
};
would work better…
What about just this:
for (var i = 1; i === null; i++){
console.log(i*9999*9999);
};
What about just this…
for (var i = 1;var i <1;i++) {
    console.log(i);
};
How big the numbers are doesn't really matter, because it's probably gonna crash your browser eventually.
DrKat123
Scratcher
1000+ posts

Would this crash your browser?

comp09 wrote:

“**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
Ooops stuck in PHP and Python operators

Hamish752 wrote:

You could've just done, something simpler like this, without all those 9s
for(var i = 1; i < 1; i++) {
    console.log(i);
};
A simple yet deadly for loop, tried that and crashed my PC, wait wat

liam48D wrote:

comp09 wrote:

liam48D wrote:

comp09 wrote:

“**” is not a valid operation in JavaScript. Did you mean “Math.pow(x, y)?”
Dude, ES6!
???
Only supported by Nightly at the moment, I think.

Yeah, noticed that would happen

TheMonsterOfTheDeep wrote:

The following crashed my Chrome browser:
while(true) { console.log("true!"); } //while true doesn't like you! :D
And I can make it worse:
var killBrowser = function() {
    while(true) { setInterval(killBrowser, 10); }
}
killBrowser();
This is, of course, essentially the same as the for loop with no exit condition. :package:
Wow, while true really doesn't like you.

Btw tried my modified script on the browser's console; and it only slows down my computer to a crash
TheMonsterOfTheDeep
Scratcher
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
Scratcher
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
Scratcher
1000+ posts

Would this crash your browser?

DrKat123 wrote:

Hamish752 wrote:

You could've just done, something simpler like this, without all those 9s
for(var i = 1; i < 1; i++) {
    console.log(i);
};
A simple yet deadly for loop, tried that and crashed my PC, wait wat
Simple scripts, are the best scripts

Last edited by Hamish752 (Dec. 28, 2015 08:53:39)

DrKat123
Scratcher
1000+ posts

Would this crash your browser?

Hamish752 wrote:

DrKat123 wrote:

Hamish752 wrote:

You could've just done, something simpler like this, without all those 9s
for(var i = 1; i < 1; i++) {
    console.log(i);
};
A simple yet deadly for loop, tried that and crashed my PC, wait wat
Simple scripts, are the best scripts
I ♥ Mininalistic and simple scrpts XD
What if you run this
var y = 100;
while (y > 0){
//do pointless stuff or other things here
//wait wat no y--
};
Slow down, yes, not crash your browser
Jonathan50
Scratcher
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
Forum Moderator
500+ posts

Would this crash your browser?

TheMonsterOfTheDeep wrote:

The following crashed my Chrome browser:
while(true) { console.log("true!"); } //while true doesn't like you! :D
And I can make it worse:
var killBrowser = function() {
    while(true) { setInterval(killBrowser, 10); }
}
killBrowser();
This is, of course, essentially the same as the for loop with no exit condition. :package:

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
Scratcher
1000+ posts

Would this crash your browser?

Jonathan50 wrote:

// -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
Wow. My computer frozed but I managed to switch to a virtual TTY and stop it with
while true; do killall icecat; done
but when I reopened IceCat then it reopened all the tabs and kept going… lol

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)

Powered by DjangoBB