Skip to content

Fix crash when fallback workspace is in the removal set#53549

Merged
rtfeldman merged 2 commits intomainfrom
fix-fallback-workspace-panic
Apr 13, 2026
Merged

Fix crash when fallback workspace is in the removal set#53549
rtfeldman merged 2 commits intomainfrom
fix-fallback-workspace-panic

Conversation

@rtfeldman
Copy link
Copy Markdown
Contributor

@rtfeldman rtfeldman commented Apr 9, 2026

When removing a project group, the fallback closure calls find_or_create_local_workspace which searches self.workspaces for an existing match. Because the workspaces to be removed haven't been removed yet at that point, workspace_for_paths can return a doomed workspace, hitting the assert! in MultiWorkspace::remove and crashing the app.

Fix by adding an excluding parameter to find_or_create_local_workspace so callers inside removal fallbacks can skip workspaces that are about to be removed. Both remove_project_group and sidebar::archive_thread now pass the appropriate exclusion set.

Adds a regression test that deterministically reproduces the crash (the assert fires without the exclusion, passes with it).

Release Notes:

  • Fixed a crash when closing a project group whose fallback workspace matched one being removed.
@rtfeldman rtfeldman self-assigned this Apr 9, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 9, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Apr 9, 2026
@rtfeldman rtfeldman force-pushed the fix-fallback-workspace-panic branch from beebc13 to 0df1669 Compare April 9, 2026 20:54
When removing a project group, the fallback closure calls
find_or_create_local_workspace which searches self.workspaces for an
existing match. Because the workspaces to be removed haven't been
removed yet at that point, workspace_for_paths can return a doomed
workspace, hitting the assert in MultiWorkspace::remove.

Fix by adding an `excluding` parameter to find_or_create_local_workspace
so callers inside removal fallbacks can skip workspaces that are about
to be removed. Both remove_project_group and sidebar::archive_thread
now pass the appropriate exclusion set.
@rtfeldman rtfeldman force-pushed the fix-fallback-workspace-panic branch from 0df1669 to c15c5bf Compare April 9, 2026 21:09
# Conflicts:
#	crates/workspace/src/multi_workspace.rs
#	crates/workspace/src/persistence.rs
@rtfeldman rtfeldman force-pushed the fix-fallback-workspace-panic branch from a7cebe9 to 7e917af Compare April 13, 2026 16:58
@rtfeldman rtfeldman marked this pull request as ready for review April 13, 2026 20:29
@rtfeldman rtfeldman merged commit 1150c9d into main Apr 13, 2026
50 of 52 checks passed
@rtfeldman rtfeldman deleted the fix-fallback-workspace-panic branch April 13, 2026 20:30
piper-of-dawn pushed a commit to piper-of-dawn/zed that referenced this pull request Apr 25, 2026
…es#53549)

When removing a project group, the fallback closure calls
`find_or_create_local_workspace` which searches `self.workspaces` for an
existing match. Because the workspaces to be removed haven't been
removed yet at that point, `workspace_for_paths` can return a doomed
workspace, hitting the `assert!` in `MultiWorkspace::remove` and
crashing the app.

Fix by adding an `excluding` parameter to
`find_or_create_local_workspace` so callers inside removal fallbacks can
skip workspaces that are about to be removed. Both
`remove_project_group` and `sidebar::archive_thread` now pass the
appropriate exclusion set.

Adds a regression test that deterministically reproduces the crash (the
assert fires without the exclusion, passes with it).

Release Notes:

- Fixed a crash when closing a project group whose fallback workspace
matched one being removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

2 participants