Skip to content

Fix wasmtime panic handling#49944

Merged
ConradIrwin merged 1 commit intomainfrom
wasmtime-panics
Feb 24, 2026
Merged

Fix wasmtime panic handling#49944
ConradIrwin merged 1 commit intomainfrom
wasmtime-panics

Conversation

@ConradIrwin
Copy link
Member

@ConradIrwin ConradIrwin commented Feb 24, 2026

We see a number of crashes in Sentry that appear to be crashes in wasmtime.
This shouldn't happen, as wasmtime is designed to run untrusted code "safely".

Looking into this, it seems likely that the problem is that we race with wasmtime
when installing signal handlers. If wasmtime's handlers are installed before ours,
then any signals that it intends to handle (like out of bounds memory access) will
reach our handlers before its; which causes us to assume the app has crashed.

This changes fixes our crash handler initialization to ensure we always create
our signal handler first, and reverts a previous attempt to fix this from #40883

Closes #ISSUE

Before you mark this PR as ready for review, make sure that you have:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects
  • Aligned any UI changes with the UI checklist

Release Notes:

  • Linux: Fixed crashes that could happen due to our crash handler erroneously catching signals intended for wasmtime.

Previously we raced when setting up signal handlers. On Linux this meant
that sometimes wasmtime would inject its signal handlers before ours, and
so when we added ours, we'd see faults from wasmtime, assume they were
crashes, and tear down the app.

This PR fixes that by ensuring we install the signal handlers
immediately, and then boot up the crash handler in the background.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 24, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 24, 2026
@ConradIrwin ConradIrwin merged commit 61e7746 into main Feb 24, 2026
38 checks passed
@ConradIrwin ConradIrwin deleted the wasmtime-panics branch February 24, 2026 04:44
Anthony-Eid pushed a commit to bobbymannino/zed that referenced this pull request Feb 25, 2026
We see a number of crashes in Sentry that appear to be crashes in
wasmtime.
This shouldn't happen, as wasmtime is designed to run untrusted code
"safely".

Looking into this, it seems likely that the problem is that we race with
wasmtime
when installing signal handlers. If wasmtime's handlers are installed
before ours,
then any signals that it intends to handle (like out of bounds memory
access) will
reach our handlers before its; which causes us to assume the app has
crashed.

This changes fixes our crash handler initialization to ensure we always
create
our signal handler first, and reverts a previous attempt to fix this
from zed-industries#40883

Closes #ISSUE

Before you mark this PR as ready for review, make sure that you have:
- [ ] Added a solid test coverage and/or screenshots from doing manual
testing
- [ ] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Linux: Fixed crashes that could happen due to our crash handler
erroneously catching signals intended for wasmtime.
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
We see a number of crashes in Sentry that appear to be crashes in
wasmtime.
This shouldn't happen, as wasmtime is designed to run untrusted code
"safely".

Looking into this, it seems likely that the problem is that we race with
wasmtime
when installing signal handlers. If wasmtime's handlers are installed
before ours,
then any signals that it intends to handle (like out of bounds memory
access) will
reach our handlers before its; which causes us to assume the app has
crashed.

This changes fixes our crash handler initialization to ensure we always
create
our signal handler first, and reverts a previous attempt to fix this
from zed-industries#40883

Closes #ISSUE

Before you mark this PR as ready for review, make sure that you have:
- [ ] Added a solid test coverage and/or screenshots from doing manual
testing
- [ ] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Linux: Fixed crashes that could happen due to our crash handler
erroneously catching signals intended for wasmtime.
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