50

Trying to set window.location or using window.navigate() to make the browser go to about:crash or chrome://crash doesn't work. Is there a way to do it?

trusktr
  • 44,284
  • 53
  • 191
  • 263
  • Is there a point to this? I mean I actually don't know. But is there? – karim79 Jun 10 '12 at 02:34
  • 5
    Create an infinite loop and sit back. – j08691 Jun 10 '12 at 02:39
  • Probably the browser doesn't allow manually pointing to those pages for security reason. I think you can kill some child process of Chrome to simulate a crash. – nhahtdh Jun 10 '12 at 02:57
  • 4
    @karim79 The point is for crash handling. I need to make my Chrome extension crash in order to know how to recover from the crash... I have multiple extensions all communicating together acting as one. When the main controller extension detects that one of it's manipulated extensions has crashed, it needs to know at what state it was in and how to restore it (and avoid crashing again). – trusktr Jun 10 '12 at 03:43

6 Answers6

97

FUN FUN LOOP:

txt = "a";
while(1){
    txt = txt += "a";    //add as much as the browser can handle
}
//[evil laugh] BOOM! All memory used up, and it is now CRASHED!

http://jsfiddle.net/DerekL/M45Cn/1/

enter image description here

Sorry for the Chinese characters...


Extra

Fun Fun Loop also works on Firefox! enter image description here

And I have to give an applause to Safari, because it automatically reload the page when it is about to crash! Good job Webkit developers!

Oh yeah...

WARNING: Don't try it in Internet Explorer... Because it crashed not my browser, instead, it crashed my Windows 7... enter image description here Yes. I have to restart the computer after that thing.

Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
63

I realize this question is over a year old, but apparently you can use chrome://inducebrowsercrashforrealz.

Here is a list of additional debug chrome:// URLs, taken from chrome://about:

chrome://crash
chrome://kill
chrome://hang
chrome://shorthang
chrome://gpuclean
chrome://gpucrash
chrome://gpuhang
chrome://ppapiflashcrash
chrome://ppapiflashhang
chrome://restart
alexia
  • 14,440
  • 8
  • 42
  • 52
  • 24
    Important note: `chrome://inducebrowsercrashforrealz` will crash **the top-level process for Chrome, including all tabs in all browser windows and all opened apps,** not just the current tab as `chrome://crash` or `chrome://kill` will. – Stuart P. Bentley Jan 11 '15 at 09:25
  • 8
    Who would give such a deadly weapon such a cute name? – Jack G Feb 01 '18 at 01:14
9

This is by far the most simple way. Create an Array with the largest number possible for Arrays. This will not take up a computer's memory, but it will crash the page in a number of seconds.

[...Array(2**32-1)]

Let's say that your computer can handle this (it shouldn't). Try this to give your computer more stress:

[...Array(2**32-1)].map(_=>Math.ceil(Math.random()*111))

These can be called from the address bar with:

javascript:[...Array(2**32-1)]

or

javascript:[...Array(2**32-1)].map(_=>Math.ceil(Math.random()*111))
Community
  • 1
  • 1
myjobistobehappy
  • 736
  • 5
  • 16
  • When I run it, my computer is perfectly fine and I get `[30, 46, 79, 57, 97, 5, 18, 34, 86, 39, 108, 34, 30, 102, 98, 109, 84, 100, 25, 6, 5, 111, 39, 103, 45, 18, 93, 16, 57, 38, 8, 54, 84, 86, 17, 104, 12, 65, 7, 18, 74, 37, 39, 76, 66, 80, 88, 78, 21, 55, 89, 65, 22, 3, 81, 55, 106, 29, 6, 15, 24, 31, 48, 46, 82, 78, 4, 105, 21, 18, 7, 73, 73, 28, 9, 82, 48, 93, 57, 3, 86, 82, 2, 86, 9, 110, 64, 10, 74, 62, 11, 95, 25, 47, 3, 38, 42, 84, 84, 20, …]` – YJiqdAdwTifMxGR Feb 11 '21 at 20:47
  • 1
    @Max You must have a good computer? Or a great browser ;) – myjobistobehappy Feb 17 '21 at 02:08
7

Simple enter the following line of code into the chrome address bar to see a Chrome tab crash simulation:

chrome://crash
Bob
  • 146
  • 9
Danio
  • 99
  • 1
  • 4
  • 2
    Sweet. Thanks for joining just to post this. – trusktr Sep 18 '13 at 21:43
  • 6
    Actually, chrome://crashes is where you go to see a list of crashes that have been recorded. chrome://crash is how you intentionally crash the renderer process (the tab) and chrome://crashes is how you view that crash afterwards. – Bruce Dawson Jun 15 '16 at 00:32
2

Found this on Reddit

Crashes an i5 8th Gen in a few seconds.

for (var i = 5; i > 3; i = i + 1)
  { console.log(i); }
<html>
<h1>This Should Crash Your Browser</h1>
</html>

Disclaimer

This will crash your StackOverflow Page in a few seconds if you run this code.

0

I know this question is old, but sometimes I want to seriously crash an application, so that nobody can ignore something that may be potentially missed or ignored.

I think in the context of a "traditional" web app, the best approach is to do something like this:

const error = new Error('FOO is undefined - this should never happen');
location.href = (
  '/crash'
    + '?message=' + encodeURIComponent(error.message)
    + '&stack=' + encodeURIComponent(error.stack)
);
throw error

Doing location.href = 'chrome://crash' just gives an error and does nothing.

Doing location.href = 'about:crash' basically just navigates you to 'about:blank#blocked' and gives you a white screen

Devin Rhode
  • 23,026
  • 8
  • 58
  • 72