6

Is there a "good" way to crash OS X? I need it for testing particularities.

It needs to be good enough not to cause permanent/ unrecoverable damage to the OS and hardware. I know I can just pull-plug (force shutdown via power button), but it seems dangerous to the hardware if done often.

I'm thinking possibly an app that has a ≪Crash OS≫ button? Anyone know of such a thing?

  • 1
    “Crash” really - what about the shutdown command... issued in terminal with admin rights... – Solar Mike Feb 16 '18 at 7:40
  • 1
    What do you mean by crash? And what means „damage“? Any crash/kernel panic can lead to corrupted data for instance. – nohillside Feb 16 '18 at 8:28
  • 2
    As it‘s nearly impossible to reliably crash macOS from user space a self-developed kernel extension might be a way. Or just run shutdown or halt. – nohillside Feb 16 '18 at 8:30
  • 3
    I'm a little confused as to what you're trying to emulate here. Perhaps you could define crash more definitively? For example, do you want a kernel panic? Or, do you want the OS to freeze? Or, is it just that you want the Mac to power off (i.e. shutdown) or reboot suddenly in a non-graceful way? In your comment to @patrix you do mention there are Windows apps that do what you want, so perhaps you could list a couple to help clarify what you need? – Monomeeth Feb 16 '18 at 9:38
  • 1
    Do your testing with a Virtual Machine! – user3439894 Feb 16 '18 at 14:17
9

I assume you mean kernel panic:

Kernel Panic, though sounding scary, is simply an occurrence when your Mac restarts for no obvious reason. Your Mac’s screen goes black giving you various warning messages like “You need to restart your computer.” Note that the presence of the warning message is what distinguishes Kernel Panic from usual Mac restarts and app crashes. In other words, Kernel Panic is just a Mac version of “blue screen of death” on Windows.

To start a kernel panic, you can issue the following command from Terminal:

sudo dtrace -w -n "BEGIN{ panic();}"

You will need to disable SIP if you have El Capitan or later. You can find instructions to do it here. It works for any version of macOS that has SIP, but you should NOT do it unless you really need to, since it is a security risk. If you do, you should re-enable it when your work is done.

Or an even better option is to test your software in a virtual machine using a virtualization software like Parallels or VMWare. This way, you won't damage your computer in any way.

This is not completely harmless if you try it on your actual machine instead of a VM. There is no completely harmless way of crashing your system. In my case, it didn't do any damage to my system, but you have been warned.

  • Is the harm limited to the logical filesystem ("And so it's fixable?") or does it harm the hardware itself? – Pacerier Feb 16 '18 at 15:59
  • Hardware will most likely not get harmed. – pixelomer Feb 16 '18 at 16:02
  • 2
    @Pacerier It's the equivalent of disconnecting the power/battery while the computer is running. Not going to harm your hardware, but data loss is a possibility. – Wowfunhappy Feb 17 '18 at 3:18
  • 1
    It's really not a security risk if you do this testing in a Virtual Machine that's being used just for this test and this sort of testing really should not be done to the physically install and is exactly what a VM is for, among many other things. – user3439894 Feb 19 '18 at 16:37
  • 1
    @danielAzuelos the filesystem can be damaged if writes are in progress which don't complete. Application data loss is also likely. Note that HFS+ and APFS have a "journal" which helps to repair the filesystem and greatly minimizes the chances of total filesystem data loss, but it still means the journal needs to be replayed. If you care about your data, make backups and try to always safely unmount disks (and a kernel panic is not a safe unmount) – Josh Feb 22 '18 at 22:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .