Skip to content

markdown_preview: Fix panic in mermaid diagram renderer#50176

Merged
smitbarmase merged 2 commits intomainfrom
fix-mermaid-diagram-internal-lib-panic
Feb 26, 2026
Merged

markdown_preview: Fix panic in mermaid diagram renderer#50176
smitbarmase merged 2 commits intomainfrom
fix-mermaid-diagram-internal-lib-panic

Conversation

@smitbarmase
Copy link
Copy Markdown
Member

@smitbarmase smitbarmase commented Feb 26, 2026

The mermaid renderer can fail to render certain diagrams, and we already have a fallback for that. It's not worth crashing Zed over it.

Wrapping catch_unwind alone doesn't work because our panic hooks terminate the process before unwinding begins (we intentionally terminate so the crash handler subprocess can generate a minidump), so there was no way to gracefully handle panics from third-party code until now (in rare cases where we need it, like in this case).

To handle this gracefully, we added crashes::recoverable_panic which tells the panic hook to stand down on the current thread so the unwind can proceed and be caught. This should be used sparingly since caught panics bypass crash reporting.

Release Notes:

  • Fixed a crash when rendering mermaid diagrams in markdown preview.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 26, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 26, 2026
@smitbarmase smitbarmase merged commit a25d124 into main Feb 26, 2026
44 of 46 checks passed
@smitbarmase smitbarmase deleted the fix-mermaid-diagram-internal-lib-panic branch February 26, 2026 10:11
rtfeldman pushed a commit that referenced this pull request Feb 27, 2026
The mermaid renderer can fail to render certain diagrams, and we already
have a fallback for that. It's not worth crashing Zed over it.

Wrapping `catch_unwind` alone doesn't work because our panic hooks
terminate the process before unwinding begins (we intentionally
terminate so the crash handler subprocess can generate a minidump), so
there was no way to gracefully handle panics from third-party code until
now (in rare cases where we need it, like in this case).

To handle this gracefully, we added `crashes::recoverable_panic` which
tells the panic hook to stand down on the current thread so the unwind
can proceed and be caught. This should be used sparingly since caught
panics bypass crash reporting.

Release Notes:

- Fixed a crash when rendering mermaid diagrams in markdown preview.
smitbarmase added a commit that referenced this pull request Mar 2, 2026
…ing panic (#50470)

#50176 added `recoverable_panic` to swallow mermaid panics, then #50280
fixed it in upstream. This PR removes the workaround so future panics
reach Sentry. Also bumps `mermaid-rs-renderer` to fix a hex parsing
panic.

Release Notes:

- N/A
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
…es#50176)

The mermaid renderer can fail to render certain diagrams, and we already
have a fallback for that. It's not worth crashing Zed over it.

Wrapping `catch_unwind` alone doesn't work because our panic hooks
terminate the process before unwinding begins (we intentionally
terminate so the crash handler subprocess can generate a minidump), so
there was no way to gracefully handle panics from third-party code until
now (in rare cases where we need it, like in this case).

To handle this gracefully, we added `crashes::recoverable_panic` which
tells the panic hook to stand down on the current thread so the unwind
can proceed and be caught. This should be used sparingly since caught
panics bypass crash reporting.

Release Notes:

- Fixed a crash when rendering mermaid diagrams in markdown preview.
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
…ing panic (zed-industries#50470)

zed-industries#50176 added `recoverable_panic` to swallow mermaid panics, then zed-industries#50280
fixed it in upstream. This PR removes the workaround so future panics
reach Sentry. Also bumps `mermaid-rs-renderer` to fix a hex parsing
panic.

Release Notes:

- N/A
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant