Zed Improved. Aiming to improve upon Zed and make a truly delightful code editor. https://zed.dev
Find a file
Conrad Irwin a2e98e9f0e
Fix potential race-condition in DisplayLink::drop on macOS (#32116)
Fix a segfault in CVDisplayLink

We see 1-2 crashes a day on macOS on the `CVDisplayLink` thread.

```
Segmentation fault: 11 on thread 9325960 (CVDisplayLink)
CoreVideo	CVHWTime::reset()
CoreVideo	CVXTime::reset()
CoreVideo	CVDisplayLink::runIOThread()
libsystem_pthread.dylib	_pthread_start
libsystem_pthread.dylib	thread_start
```

With the help of the Zed AI, I dove into the crash report, which looks
like this:

```
Crashed Thread:        49  CVDisplayLink

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000000000001f6
Exception Codes:       0x0000000000000001, 0x00000000000001f6

Thread 49 Crashed:: CVDisplayLink
0   CoreVideo                     	       0x18c1ed994 CVHWTime::reset() + 64
1   CoreVideo                     	       0x18c1ee474 CVXTime::reset() + 52
2   CoreVideo                     	       0x18c1ee198 CVDisplayLink::runIOThread() + 176
3   libsystem_pthread.dylib       	       0x18285ac0c _pthread_start + 136
4   libsystem_pthread.dylib       	       0x182855b80 thread_start + 8

Thread 49 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x000000018c206e08   x2: 0x0000002c00001513   x3: 0x0001d4630002a433
    x4: 0x00000e2100000000   x5: 0x0001d46300000000   x6: 0x000000000000002c   x7: 0x0000000000000000
    x8: 0x000000000000002e   x9: 0x000000004d555458  x10: 0x0000000000000000  x11: 0x0000000000000000
   x12: 0x0000000000000000  x13: 0x0000000000000000  x14: 0x0000000000000000  x15: 0x0000000000000000
   x16: 0x0000000182856a9c  x17: 0x00000001f19bc540  x18: 0x0000000000000000  x19: 0x0000600003c56ed8
   x20: 0x000000000002a433  x21: 0x0000000000000000  x22: 0x0000000000000000  x23: 0x0000000000000000
   x24: 0x0000000000000000  x25: 0x0000000000000000  x26: 0x0000000000000000  x27: 0x0000000000000000
   x28: 0x0000000000000000   fp: 0x000000016b02ade0   lr: 0x000000018c1ed984
    sp: 0x000000016b02adc0   pc: 0x000000018c1ed994 cpsr: 0x80001000
   far: 0x00000000000001f6  esr: 0x92000006 (Data Abort) byte read Translation fault

Binary Images:
       0x1828c9000 -        0x182e07fff com.apple.CoreFoundation (6.9) <df489a59-b4f6-32b8-9bb4-9b832960aa52> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
```

Using lldb to disassemble `CVHWTime::reset()` (and the AI to interpret
it), the crash is caused by dereferencing the pointer at the start of
the CVHWTime struct + 0x1c8. In this case the pointer has (the clearly
nonsense) value 0x2e (and 0x2e + 0x1c8 = 0x1f6, the failing address).

As to how this could happen...

Looking at the implementation of `CVDisplayLinkRelease`, it calls
straight into `CFRelease` on the main thread; and so it is not safe to
call `CVDisplayLinkRelease` concurrently with other threads that access
the CVDisplayLink. While we already stopped the display link, it turns
out that `CVDisplayLinkStop` just sets a flag on the struct to instruct
the io-thread to exit "soon", and returns immediately. That means we
don't know when the other thread will actually exit, and so we can't
safely call `CVDisplayLinkRelease`.

So, for now, we just leak these objects. They should be created
relatively infrequently (when the app is foregrounded/backgrounded), so
I don't think this is a huge problem.

Release Notes:

- Fix a rare crash on macOS when putting the app in the background.
2025-06-04 17:10:27 -06:00
.cargo build: Remove -all_load linker argument on macOS (#30656) 2025-05-17 07:20:23 +02:00
.cloudflare docs: Document context servers (#21170) 2024-11-25 11:05:14 -05:00
.config workspace-hack: remove openssl from remote_server (#27990) 2025-04-03 00:49:07 +00:00
.github Validate actions in docs (#31073) 2025-06-04 19:18:12 +00:00
.zed Update debug.json in Zed repo to run the build on session startup (#31707) 2025-05-29 21:29:18 +02:00
assets Validate actions in docs (#31073) 2025-06-04 19:18:12 +00:00
crates Fix potential race-condition in DisplayLink::drop on macOS (#32116) 2025-06-04 17:10:27 -06:00
docs Validate actions in docs (#31073) 2025-06-04 19:18:12 +00:00
extensions toml: Bump to v0.1.4 (#31272) 2025-05-23 12:18:24 +00:00
legal Legal Terms: May 6th 2025 update (#30151) 2025-05-07 17:14:02 +00:00
nix nix: Make zeditor symlink in package output (#31354) 2025-05-26 08:59:52 -07:00
script Add a script to connect to the database. (#32023) 2025-06-04 09:23:23 -06:00
tooling Disallow running Zed with root privileges (#31331) 2025-05-30 21:22:52 +00:00
.clinerules Initial .rules file for agent with symlinks for other rules file paths (#29014) 2025-04-17 23:41:23 +00:00
.cursorrules Initial .rules file for agent with symlinks for other rules file paths (#29014) 2025-04-17 23:41:23 +00:00
.git-blame-ignore-revs Add PR 15352 to .git-blame-ignore-revs (#30870) 2025-05-17 11:35:58 +00:00
.gitattributes Prevent GitHub from displaying comments within JSON files as errors (#7043) 2024-01-29 23:11:25 -05:00
.gitignore Update nixpkgs, add direnv to gitignore (#30292) 2025-05-13 01:45:22 -07:00
.mailmap Update .mailmap (#30874) 2025-05-17 12:34:42 +00:00
.prettierrc ci: Add check for formatting default.json (#30034) 2025-05-06 18:55:26 +00:00
.rules Add channel reordering functionality (#31833) 2025-06-04 16:56:33 +00:00
.windsurfrules Initial .rules file for agent with symlinks for other rules file paths (#29014) 2025-04-17 23:41:23 +00:00
Cargo.lock Validate actions in docs (#31073) 2025-06-04 19:18:12 +00:00
Cargo.toml Bump tree-sitter-bash to 0.25 (#32091) 2025-06-04 13:22:34 -04:00
CLAUDE.md Initial .rules file for agent with symlinks for other rules file paths (#29014) 2025-04-17 23:41:23 +00:00
clippy.toml Restructure agent context (#29233) 2025-04-24 21:29:33 +00:00
CODE_OF_CONDUCT.md Remove community content from docs and point to zed.dev (#19895) 2024-10-29 09:44:58 -04:00
compose.yml Add Postgrest to Docker Compose (#16498) 2024-08-19 20:50:45 -04:00
CONTRIBUTING.md Allow icon themes to provide their own file associations (#24926) 2025-02-15 00:35:13 +00:00
Cross.toml Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
debug.plist WIP 2023-12-14 09:25:14 -07:00
default.nix Fix nix build (#26270) 2025-03-10 01:06:11 -07:00
docker-compose.sql collab: Setup database for LLM service (#15882) 2024-08-06 17:18:08 -04:00
Dockerfile-collab chore: Bump Rust to 1.87 (#30739) 2025-05-15 22:28:52 +00:00
Dockerfile-collab.dockerignore ci: Move collab to Dockerfile-collab (#18515) 2024-09-30 16:14:26 -04:00
Dockerfile-cross Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
Dockerfile-cross.dockerignore Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
Dockerfile-distros Support More Linux (#18480) 2024-09-30 17:46:21 -04:00
Dockerfile-distros.dockerignore Support More Linux (#18480) 2024-09-30 17:46:21 -04:00
flake.lock nix: Refactor gh-actions and re-enable nightly builds (#31489) 2025-05-27 11:34:15 -07:00
flake.nix nix: Add job names and garnix substitutor (#31625) 2025-05-28 13:32:12 -07:00
LICENSE-AGPL Update license year (#24191) 2025-02-04 09:02:59 -05:00
LICENSE-APACHE Update license year (#24191) 2025-02-04 09:02:59 -05:00
LICENSE-GPL Licenses: change license fields in Cargo.toml to AGPL-3.0-or-later. (#5535) 2024-01-27 13:51:16 +01:00
livekit.yaml Add LiveKit server to Docker Compose (#7907) 2024-02-16 10:49:48 -05:00
Procfile Refactor: Restructure collab main function to prepare for new subcommand: serve llm (#15824) 2024-08-05 12:07:38 -07:00
Procfile.postgrest Fix llm queries (#16006) 2024-08-08 17:21:38 -07:00
README.md Remove Repology badge from README (#30857) 2025-05-17 07:01:46 +00:00
renovate.json renovate: Require dependency dashboard approval for updates (#29065) 2025-04-18 18:44:30 +00:00
rust-toolchain.toml extension: Update to wasm32-wasip2 target (#30953) 2025-05-26 16:06:38 +02:00
shell.nix Fix nix build (#26270) 2025-03-10 01:06:11 -07:00
typos.toml editor: Handle more completion sort cases (#30690) 2025-05-14 18:49:39 +05:30

Zed

CI

Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.


Installation

On macOS and Linux you can download Zed directly or install Zed via your local package manager.

Other platforms are not yet available:

Developing Zed

Contributing

See CONTRIBUTING.md for ways you can contribute to Zed.

Also... we're hiring! Check out our jobs page for open roles.

Licensing

License information for third party dependencies must be correctly provided for CI to pass.

We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:

  • Is it showing a no license specified error for a crate you've created? If so, add publish = false under [package] in your crate's Cargo.toml.
  • Is the error failed to satisfy license requirements for a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to the accepted array in script/licenses/zed-licenses.toml.
  • Is cargo-about unable to find the license for a dependency? If so, add a clarification field at the end of script/licenses/zed-licenses.toml, as specified in the cargo-about book.