Skip to content

debugger: Fix crash when dragging pane items to split view#46806

Merged
Anthony-Eid merged 6 commits intozed-industries:mainfrom
xcb3d:fix-debugger-pane-drag-crash
Jan 20, 2026
Merged

debugger: Fix crash when dragging pane items to split view#46806
Anthony-Eid merged 6 commits intozed-industries:mainfrom
xcb3d:fix-debugger-pane-drag-crash

Conversation

@xcb3d
Copy link
Contributor

@xcb3d xcb3d commented Jan 14, 2026

Closes #46784

This panic was caused by a double borrow when the pane an item was moved too is the same pane the item originate from. The fix was using a window.defer to avoid the double lease, instead of updating in a Context<Pane>

Release Notes:

  • debugger: Fix crash when splitting a pane by dragging a pane item that originated from that pane

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 14, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jan 14, 2026
@xcb3d xcb3d force-pushed the fix-debugger-pane-drag-crash branch from cd75b22 to 29901f9 Compare January 14, 2026 15:56
- Defer split+move operation via cx.spawn_in() to avoid double borrow of Pane entity
- Replace unwrap() with graceful returns in activate_item and run_in_terminal
- Handle members/bounding_boxes length mismatch in pane_at_pixel_position

Closes zed-industries#46784
@xcb3d xcb3d force-pushed the fix-debugger-pane-drag-crash branch from 29901f9 to 79aa9bc Compare January 14, 2026 15:58
@xcb3d
Copy link
Contributor Author

xcb3d commented Jan 15, 2026

Hi @Anthony-Eid, ready for review! Please take a look whenever you have a moment. Thanks!

Comment on lines +880 to +883
debug_assert!(self.members.len() == self.bounding_boxes.lock().len());

let bounding_boxes = self.bounding_boxes.lock();
if self.members.len() != bounding_boxes.len() {
return None;
}
Copy link
Contributor

@Anthony-Eid Anthony-Eid Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave the debug_assert here.

If this assertion fails in a debug build that means there's another bug we have to fix

Add debug assertion to help detect underlying bug in debug builds.
@xcb3d
Copy link
Contributor Author

xcb3d commented Jan 16, 2026

Hi @Anthony-Eid. Added debug_assert! back per review feedback. Ready for re-review.

@xcb3d xcb3d requested a review from Anthony-Eid January 17, 2026 04:13
@xcb3d
Copy link
Contributor Author

xcb3d commented Jan 20, 2026

Hi @Anthony-Eid, everything is ready for preview. Could you please take a look when you have a moment? Thanks!

@Anthony-Eid Anthony-Eid enabled auto-merge (squash) January 20, 2026 17:21
@Anthony-Eid Anthony-Eid merged commit a8bf82c into zed-industries:main Jan 20, 2026
77 of 83 checks passed
@Anthony-Eid
Copy link
Contributor

/cherry-pick preview

@zed-zippy
Copy link
Contributor

zed-zippy bot commented Jan 28, 2026

🍒💥 Cherry-pick did not succeed
https://github.com/zed-industries/zed/actions/runs/21420128777

Anthony-Eid added a commit that referenced this pull request Jan 28, 2026
…t originated from that pane (#46806)

Closes #46784

This panic was caused by a double borrow when the pane an item was moved too is the same pane the item originate from. The fix was using a window.defer to avoid the double lease, instead of updating in a Context<Pane>

Release Notes:

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
zcg pushed a commit to zcg/zedpro that referenced this pull request Jan 29, 2026
…tries#46806)

## Summary

Fixes crash when dragging debugger panel items
(terminal/console/variables/frames) to another pane as split view.

  **Root causes:**
1. Double borrow panic - `pane_group.split()` was called synchronously
inside a `Context<Pane>` update, causing "cannot update Pane while it is
already being updated"
2. `unwrap()` calls that panic when items are in transition during drag
operations
3. `debug_assert!` in `pane_at_pixel_position` fails when `members` and
`bounding_boxes` are temporarily out of sync after deferred split

  **Fixes:**
- Defer entire split+move operation via `cx.spawn_in()` to avoid double
borrow
- Replace `unwrap()` with graceful early returns in `activate_item` and
`run_in_terminal`
- Handle `members.len() != bounding_boxes.len()` gracefully in
`pane_at_pixel_position`

Closes zed-industries#46784

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
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 first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zed crashes during debug when a debug pane (terminal, console, etc.) is moved to another one

2 participants