macos 调用 Mac 内核恐慌?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8828329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:46:13  来源:igfitidea点击:

Invoke Mac Kernel Panic?

macoskernel

提问by Trevor Rudolph

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.

所以我正在寻找一些源代码来使 mac 内核崩溃。我找到了 debain linux 的 crashme,但这不适用于 mac 内核。所以我想知道是否有人知道我在哪里可以找到命令行实用程序或一些源代码来调用 mac 内核恐慌?这将是一个巨大的帮助,谢谢。

回答by Chuck

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

Apple 有一份关于如何做到这一点的技术说明。简单的方法是使用这个命令,sudo dtrace -w -n "BEGIN{ panic();}"从终端运行。

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.

2020 年更新:正如 Wei Shen 在评论中所指出的,您需要禁用 SIP 才能使其在现代 macOS 版本中工作。

回答by George Carrette

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.

我最近更新了 crashme 以在 Mac OS X Lion 上工作。您需要从http://crashme.codeplex.com/下载源代码并使用 Xcode 命令行工具编译它。问题 5085136 的答案中有更多详细信息。但请注意,crashme 尚未在 Mac 上发现任何直接的内核恐慌。然而,在本机 MacBook Pro 上运行 crashme 并在同一台机器上的 VirtualBox VM 中运行它之后,一个在 x86 PC-BSD 和另一个在 x64 Centos 中,我的 Lion 内核变得不开心,它引发了几次内核恐慌几分钟后,当我使用本机 Emacs 编辑文件时。因此,crashme 可能偶然发现了一个内核错误。

回答by Matt

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

进入终端并输入“killall kernel_task”,它应该会强制计算机进入恐慌状态,而无需下载任何软件。在尝试之前,请确保已保存所有内容:D

回答by Chris Martin

although this requires a password it works every time sudo halt

虽然这需要密码,但它每次都有效 sudo halt