zed icon indicating copy to clipboard operation
zed copied to clipboard

macOS 14.4 panic when running Zed & Ghostty

Open moomerman opened this issue 1 year ago • 27 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

I upgraded to macOS 14.4 over the weekend and this morning my Mac panics every time I open Zed. It looks like this issue might not be limited to Zed, but I thought it was worth registering the issue anyway in case anyone else has the same problem.

I've been using my laptop for a while this morning with no issue, only seems to be Zed that is triggering this for me at the moment.

This apple discussion thread has some similar reports from other apps.

I cleared out my ~/Library/Application Support/Zed folder and tried opening zed with a folder that only contained a text file (to rule out any issues with language server etc.) but still had the same problem.

Let me know if I can provide any more info, happy to send full crash log and zed logs privately.

The behaviour is:

  • Launch Zed
  • Within a few seconds the screen freezes
  • A couple of seconds later black screen
  • Then apple icon shown and reboots

When I log back in, I have to quickly quit Zed otherwise it loops again!

Environment

I can't run Zed to run this command :(

Chip: Apple M2 Pro Memory: 16GB macOS: 14.4 (23E214)

If applicable, add mockups / screenshots to help explain present your vision of the feature

Apple crash log header:

panic(cpu 3 caller 0xfffffe002bc00e5c): DCP0 PANIC - program_swap: Async Swap request landing on unsupported platform. Force panic
 - iomfb_mailbox_async(77)
program_swap: Async Swap request landing on unsupported platform. Force panic

RTKit: RTKit-2419.101.1.release - Client: local-t602xdcp.RELEASE
!UUID: 10178379-fe92-3317-9095-ad703b8bb255
Time: 0x000000006061c421

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

Here's all the error logs and starting zed info logs from this morning:

2024-03-18T10:37:15+00:00 [INFO] ========== starting zed ==========
2024-03-18T10:37:15+00:00 [ERROR] crates/zed/src/zed.rs:619: EOF while parsing a value at line 1 column 0
2024-03-18T10:37:22+00:00 [ERROR] unexpected item event after pane was dropped
2024-03-18T10:38:09+00:00 [INFO] ========== starting zed ==========
2024-03-18T10:38:09+00:00 [ERROR] crates/zed/src/zed.rs:619: EOF while parsing a value at line 1 column 0
2024-03-18T10:38:10+00:00 [ERROR] auto-update failed: error:failed to resolve host name
2024-03-18T10:38:10+00:00 [ERROR] crates/zed/src/main.rs:323: failed to resolve host name
2024-03-18T10:38:11+00:00 [ERROR] failed to start language server "elixir-ls": error fetching latest release
2024-03-18T10:38:11+00:00 [ERROR] server stderr: Some("")
2024-03-18T10:38:12+00:00 [ERROR] failed to start language server "elixir-ls": error fetching latest release
2024-03-18T10:38:12+00:00 [ERROR] server stderr: Some("")
2024-03-18T10:38:13+00:00 [ERROR] missing executable in directory "/Users/richard/Library/Application Support/Zed/languages/elixir-ls/elixir-ls/language_server.sh"
2024-03-18T10:38:13+00:00 [ERROR] failed to start language server "elixir-ls": error fetching latest release
2024-03-18T10:38:13+00:00 [ERROR] server stderr: Some("")
2024-03-18T10:38:14+00:00 [ERROR] missing executable in directory "/Users/richard/Library/Application Support/Zed/languages/elixir-ls/elixir-ls/language_server.sh"
2024-03-18T10:38:14+00:00 [ERROR] failed to start language server "elixir-ls": error fetching latest release
2024-03-18T10:38:14+00:00 [ERROR] server stderr: Some("")
2024-03-18T10:38:15+00:00 [ERROR] missing executable in directory "/Users/richard/Library/Application Support/Zed/languages/elixir-ls/elixir-ls/language_server.sh"
2024-03-18T10:38:15+00:00 [ERROR] failed to start language server "elixir-ls": error fetching latest release
2024-03-18T10:38:15+00:00 [ERROR] server stderr: Some("")
2024-03-18T10:38:15+00:00 [ERROR] Hit 4 reinstallation attempts for "elixir-ls"
2024-03-18T10:38:57+00:00 [INFO] ========== starting zed ==========
2024-03-18T10:38:57+00:00 [ERROR] crates/zed/src/zed.rs:619: EOF while parsing a value at line 1 column 0
2024-03-18T10:38:57+00:00 [ERROR] auto-update failed: error:failed to resolve host name
2024-03-18T10:38:57+00:00 [ERROR] crates/zed/src/main.rs:323: failed to resolve host name
2024-03-18T10:39:00+00:00 [ERROR] timed out waiting on app_will_quit
2024-03-18T10:45:20+00:00 [INFO] ========== starting zed ==========
2024-03-18T10:45:20+00:00 [ERROR] crates/extension/src/extension_store.rs:266: No such file or directory (os error 2)
2024-03-18T10:45:20+00:00 [ERROR] crates/zed/src/zed.rs:619: EOF while parsing a value at line 1 column 0
2024-03-18T11:07:34+00:00 [INFO] ========== starting zed ==========
2024-03-18T11:07:34+00:00 [ERROR] crates/extension/src/extension_store.rs:266: No such file or directory (os error 2)
2024-03-18T11:07:34+00:00 [ERROR] crates/zed/src/zed.rs:619: EOF while parsing a value at line 1 column 0
2024-03-18T11:07:34+00:00 [ERROR] crates/fs/src/repository.rs:101: Error { code: -9, klass: 4, message: "reference 'refs/heads/main' not found" }
2024-03-18T11:08:22+00:00 [INFO] ========== starting zed ==========
2024-03-18T11:08:22+00:00 [ERROR] crates/zed/src/zed.rs:619: EOF while parsing a value at line 1 column 0
2024-03-18T11:08:22+00:00 [ERROR] crates/fs/src/repository.rs:101: Error { code: -9, klass: 4, message: "reference 'refs/heads/main' not found" }
2024-03-18T11:08:22+00:00 [ERROR] auto-update failed: error:failed to resolve host name
2024-03-18T11:08:22+00:00 [ERROR] crates/zed/src/main.rs:323: failed to resolve host name

moomerman avatar Mar 18 '24 11:03 moomerman

Thanks for reporting this, that's no good at all!

From scouring some Internet forums it seems like it could be related to external monitors: https://community.native-instruments.com/discussion/comment/140492/#Comment_140492

"Hi! I also noticed now - after having started to use hdmi to hdmi with the Samsung monitor, that when I set it to 240 Hz, the same thing also happens; complete crash. When set to 120 (or 60) Hz, everything runs fine!"

"I'm not 100% sure if it's display monitor related, however, what I do know is that once I used the new HDMI, it seems to work way better and I haven't had a crash yet since swapping my HDMI for a newer high speed HDMI cable."

Are you using an external display, and if so do either of these steps help you?

We'll look into this a bit to see if there's an obvious workaround, but it does seem like a macOS kernel bug if it's causing the computer to reset...

ConradIrwin avatar Mar 18 '24 19:03 ConradIrwin

Are you using an external display, and if so do either of these steps help you?

Thanks. Unfortunately I wasn't connected to any other devices, was just working directly on my laptop.

Here's a blog post from Oracle about Java issues, which says:

macOS on Apple silicon processors (M1, M2, and M3) includes a feature which controls how and when dynamically generated code can be either produced (written) or executed on a per-thread basis.

As a normal part of the just-in-time compile and execute cycle, processes running on macOS may access memory in protected memory regions. Prior to the macOS 14.4 update, in certain circumstances, the macOS kernel would respond to these protected memory accesses by sending a signal, SIGBUS or SIGSEGV, to the process. The process could then choose to handle the signal and continue execution. With macOS 14.4, when a thread is operating in the write mode, if a memory access to a protected memory region is attempted, macOS will send the signal SIGKILL instead. That signal cannot be handled by the process and the process is unconditionally terminated.

Though it seems that in that example the app crashes, but they don't mention any panics.

And an arstechnica article about other issues, which might not be relevant.

moomerman avatar Mar 18 '24 21:03 moomerman

Thanks. I do agree it sounds like the Java issue seems different (though the Kontakt player bug seems the same).

Would you be able to send the full crash report to [email protected] (or upload it here) when you get a chance? I'm not sure it'll help, but seems worth taking a look.

ConradIrwin avatar Mar 18 '24 22:03 ConradIrwin

Possibly other related thing, I notice RTKit at the top of your stack trace. In the release notes they call out:

RTKit
Available for: macOS Sonoma
Impact: An attacker with arbitrary kernel read and write capability may be able to bypass kernel memory protections. Apple is aware of a report that this issue may have been exploited.
Description: A memory corruption issue was addressed with improved validation.
CVE-2024-23296

I wonder if it's possible we are accidentally doing an out of bounds memory read/write, that previously was not a problem, but now is.

ConradIrwin avatar Mar 18 '24 23:03 ConradIrwin

I've installed 14.4 (23E214) on my test M1 MacBook Air and the good/bad news is that Zed does not seem to cause a kernel panic on boot. I tried various screen resolutions and window sizes, but it seemed fine...

So now the question is what could account for the difference?

  • The hardware is a bit different, but I don't have an M2 to test on.
  • I tested with Zed v0.126.3 and 0.127.3-pre (though I wouldn't expect the version to make much difference unless you were on v0.119 or older which was a while ago now).
  • Do you have any other display related software? (I know there are things that auto-enhance colors/ do night mode, etc.?)
  • If you quit everything else running and run just zed, does it still happen?

I'm going to try updating my main work machine and hope that I can either reproduce the problem, or we can further narrow down the circumstances in which it occurs.

ConradIrwin avatar Mar 19 '24 02:03 ConradIrwin

I tested running Zed on an M3 earlier that is running macOS 14.4 and that was fine.

I usually keep Zed up to date so it is running a recent release. It also updated this morning to the latest (before crashing).

  • If you quit everything else running and run just zed, does it still happen?

My usual workflow is to open Zed via Ghostty. It tuns out that Zed runs fine when Ghostty isn't running, and Ghostty runs fine if Zed isn't running, but if both of them are running, regardless of which one was opened first then I get the panic.

I've popped a message in the Ghostty discord as well. I'll try installing Ghostty on the M3 later and see if that also has the same behaviour.

moomerman avatar Mar 19 '24 10:03 moomerman

My usual workflow is to open Zed via Ghostty. It tuns out that Zed runs fine when Ghostty isn't running, and Ghostty runs fine if Zed isn't running, but if both of them are running, regardless of which one was opened first then I get the panic.

You don't have the Apple Metal HUD enabled by any chance? Both applications use Metal and the GPU and I wonder whether that isn't somehow related here.

mrnugget avatar Mar 19 '24 10:03 mrnugget

You don't have the Apple Metal HUD enabled by any chance?

Nope, have never enabled that before. I just enabled it and ran both apps, nothing significant happened (that I'm aware of).

moomerman avatar Mar 19 '24 11:03 moomerman

Just wanted to confirm the same issue on a M3 iMac to rule out my snowflake laptop. Same issue, crashed with the same crash report header. Saw some more reports of panics with 14.4 in the Ghostty discord as well.

Happy to try anything else you think might help track it down, but appreciate I may have to just wait until Apple releases an update. At least I can use Zed today though if I don't run Ghostty at the same time :)

moomerman avatar Mar 19 '24 12:03 moomerman

@moomerman thanks for reporting back here! In the Ghostty Discord it sounds like Apple is working on a fix. Since we can't debug this reliably and it does seems like an OS issue and we don't know exactly what the problem is, I fear that the current course of action is to cross fingers and wait for Apple to release a fix soon.

mrnugget avatar Mar 19 '24 15:03 mrnugget

After updating to macOS 14.4.1 still seeing the same issue unfortunately. Have sent a new crash report to Apple.

moomerman avatar Mar 26 '24 09:03 moomerman

Just to leave a update here, even though it's not an update: consensus on the Ghostty discord was/is that what panics is PID 0, so it's definitely a kernel bug and we have to wait for Apple to fix it.

mrnugget avatar Apr 02 '24 11:04 mrnugget

Updating from the Ghostty side: we're not for sure certain Apple is aware of this or working on a fix. We're just hoping. But I am very confident it's a kernel/firmware issue on the display coprocessor ("DCP") specifically on Apple Silicon devices.

We also still don't have a reliable reproduction to report to Apple.

mitchellh avatar Apr 02 '24 22:04 mitchellh

I have a reliable way to reproduce (unrelated to Zed): connect an Android device via USB debugging. Open scrcpy (scrcpy.org) to display the Android screen... now change the orientation of your Android device. Going from Landscape<->Portrait will trigger this panic on my 16" MBP M3 Max every time.

denovich avatar Apr 04 '24 19:04 denovich

I've got an update. Word on the street is that macOS 14.5 Beta might contain a fix, if someone is brave enough to try it.

mrnugget avatar Apr 05 '24 06:04 mrnugget

@moomerman @mitchellh @ConradIrwin I'm having the same issues running Zed and Ghostty on my M2 MacBook Air and my M3 MacBook Pro Max with and without displays connected. I am happy to email Gists with the full error outputs.

jdsimcoe avatar Apr 10 '24 16:04 jdsimcoe

I updated to the 14.5 Beta (23F5049f) and have been trying to heavily use both Zed/Ghostty and haven't had this issue once.

jdsimcoe avatar Apr 11 '24 22:04 jdsimcoe

That sounds promising! Thank you for reporting back @jdsimcoe

mrnugget avatar Apr 12 '24 04:04 mrnugget

只是在这里留下一个更新,即使它不是一个更新:对 Ghostty 不和谐的共识是,恐慌的是 PID 0,所以这绝对是一个内核错误,我们必须等待 Apple 修复它。

YES!!!!!

Panicked task 0xfffffe23599d41e8: 0 pages, 563 threads: pid 0: kernel_task Panicked thread: 0xfffffe2cf3028788, backtrace: 0xfffffe5cada27850, tid: 1078 lr: 0xfffffe001239b1c0 fp: 0xfffffe5cada278e0 lr: 0xfffffe00124e6a4c fp: 0xfffffe5cada27950 lr: 0xfffffe00124e4f18 fp: 0xfffffe5cada27a20 lr: 0xfffffe001234b8cc fp: 0xfffffe5cada27a30 lr: 0xfffffe001239aab4 fp: 0xfffffe5cada27de0 lr: 0xfffffe0012ba1814 fp: 0xfffffe5cada27e00 lr: 0xfffffe00151d3ddc fp: 0xfffffe5cada27e90 lr: 0xfffffe0014be8cd8 fp: 0xfffffe5cada27ec0 lr: 0xfffffe0012a9fd8c fp: 0xfffffe5cada27ef0 lr: 0xfffffe0012aa0904 fp: 0xfffffe5cada27f20 lr: 0xfffffe0012354be4 fp: 0x0000000000000000 Kernel Extensions in backtrace: com.apple.driver.IOSlaveProcessor(1.0)[BFD8D86E-6E2B-3FDE-8CAF-9015DF04D919]@0xfffffe0014be7b60->0xfffffe0014be9513 com.apple.driver.RTBuddy(1.0)[055E667B-789A-3D5D-9F9E-A2F951C4608E]@0xfffffe00151ae220->0xfffffe00151f05b7 dependency: com.apple.driver.AppleA7IOP(1.0.2)[047BB2D0-9A20-37B1-AA1F-DD5A6FC1283F]@0xfffffe0012ca6410->0xfffffe0012cac463 dependency: com.apple.driver.AppleARMPlatform(1.0.2)[77007C6A-68DD-3EA2-A25E-B47ACC1DAFE2]@0xfffffe0012d428b0->0xfffffe0012d95eab dependency: com.apple.driver.IOSlaveProcessor(1)[BFD8D86E-6E2B-3FDE-8CAF-9015DF04D919]@0xfffffe0014be7b60->0xfffffe0014be9513 dependency: com.apple.iokit.IOReportFamily(47)[1C7E94EA-C1DD-3617-B228-227559227E76]@0xfffffe0014b41d70->0xfffffe0014b44d83 dependency: com.apple.kec.corecrypto(14.0)[382760DA-F216-3EE0-BD95-5BE034AFCAD3]@0xfffffe001552d700->0xfffffe001557e8bb

last started kext at 10765036027: com.apple.driver.usb.cdc.ncm 5.0.0 (addr 0xfffffe00113e8600, size 5098)

ThreadGitHub avatar Apr 13 '24 03:04 ThreadGitHub

I updated to the 14.5 Beta (23F5049f) and have been trying to heavily use both Zed/Ghostty and haven't had this issue once.

With the beta I still get the crash:

panic(cpu 3 caller 0xfffffe001bd852e8): DCP PANIC - program_swap: Async Swap request landing on unsupported platform. Force panic\n
 - iomfb_driver(10)\nprogram_swap: Async Swap request landing on unsupported platform. Force panic\n\n
 RTKit: RTKit-2419.120.35.0.1.release

I simply need to have ghostty running and start Nvidia Now. It takes a few seconds and then freeze. Before the beta it was rebooting right away instead of freezing for a while before restarting.

snadon avatar Apr 17 '24 01:04 snadon

I simply need to have ghostty running and start Nvidia Now. It takes a few seconds and then freeze. Before the beta it was rebooting right away instead of freezing for a while before restarting.

So not Ghostty + Zed, but just Ghostty + Nvidia Now? Can you reproduce with Zed + Nvidia Now? (I understand if you don't want to! nobody likes to reboot)

mrnugget avatar Apr 17 '24 07:04 mrnugget

I simply need to have ghostty running and start Nvidia Now. It takes a few seconds and then freeze. Before the beta it was rebooting right away instead of freezing for a while before restarting.

So not Ghostty + Zed, but just Ghostty + Nvidia Now? Can you reproduce with Zed + Nvidia Now? (I understand if you don't want to! nobody likes to reboot)

Just tried it for 20 minutes and it didn't crash (zed version 0.131.6).

snadon avatar Apr 17 '24 16:04 snadon

🎉 I noticed by accident today that it doesn't panic with latest Zed Preview & Ghostty! Tried Zed stable and it panic'd straight away. (Still on 14.4.1)

moomerman avatar Apr 20 '24 13:04 moomerman

That's very curious, I have no clue as to what it could be after looking through the changelog.

mrnugget avatar Apr 22 '24 07:04 mrnugget

I've just been through the Zed stable releases and 0.129.2 was the last release that panics for me. Everything from Zed 0.130.4 onwards seems to be fine. I had been using preview for a while, so stable must have been on an older version when it crashed on Saturday.

All Apple Silicon releases, Ghostty542b416c (build 5944), macOS 14.4.1.

[edit] just went through the Preview releases and 0.129.1 panics but 0.130.0 doesn't.

moomerman avatar Apr 22 '24 10:04 moomerman

For Ghostty users, give the latest macOS build a shot and set the following config (new as of this comment):

window-vsync = true

After setting the config, fully restart Ghostty.

At least on my machine, I've been unable to reliably reproduce the DCP panic anymore when vsync is enabled. It isn't enabled by default at the moment but I may change that if this fixes a lot of crashes.

mitchellh avatar May 05 '24 17:05 mitchellh

After setting the config, fully restart Ghostty.

Ok I've done this. I'll report back if this issue happens again.

jdsimcoe avatar May 05 '24 18:05 jdsimcoe