8
votes

So i am lookin for some source code to crash the mac kernel. I found crashme for debain linux but that does not work for the mac kernel. So i was wondering if anyone knows where i can find a command-line utility or some source code to invoke the mac kernel panic? This would be a huge help, thanks.

4
If it's possible to deliberately invoke a kernel panic, then that is indicative of a bug in the kernel. It should not be possible to trigger a kernel panic from userland.Lily Ballard
i've doen it by force quitting an app running an apache server, a mysql server, a world of warcraft logon server and a world of warcraft world server all in one, it happens all the time.Trevor Rudolph
Either you've stumbled upon a kernel bug, or you've got a corrupted system. Kernel panics are very rare for a good reason.Lily Ballard
i can do it on any computer i install this app onTrevor Rudolph
If you already can panic a machine, why are you looking for code that panics a machine? Also, it sounds like you should report this bug.Lily Ballard

4 Answers

14
votes

Apple has a tech note about how to do this. The short way to do it is with this command, sudo dtrace -w -n "BEGIN{ panic();}", run from the terminal.

Update 2020: As noted by Wei Shen in the comments, you'll need to disable SIP to make this work in modern versons of macOS.

2
votes

I recently updated crashme to work on Mac OS X Lion. You will need to download the source code from http://crashme.codeplex.com/ and compile it using Xcode command line tools. More details are in a answer to question 5085136. But note that crashme hasn't found any immediate kernel panics on the Mac yet. However, after running crashme on the native MacBook Pro, and running it in VirtualBox VM's on the same machine, one in an x86 PC-BSD and another in an x64 Centos, my Lion Kernel became unhappy enough that it threw a kernel panic a few minutes later as I was editing a file using the native Emacs. So crashme may have stumbled upon a kernel bug.

0
votes

Go in terminal and type "killall kernel_task" it should force the computer into a panic without downloading any software. Just make sure you have everything saved before you try :D

0
votes

although this requires a password it works every time sudo halt