Skip to content

Fix handling of panics in ORPC servers#224

Merged
arthurp merged 3 commits intomainfrom
arthurp/better-panics
May 7, 2026
Merged

Fix handling of panics in ORPC servers#224
arthurp merged 3 commits intomainfrom
arthurp/better-panics

Conversation

@arthurp
Copy link
Copy Markdown
Contributor

@arthurp arthurp commented May 5, 2026

Previously, catch_unwind did not work in kernel/. It did work in ktests, which was confusing. It turns out that passing -C panic=unwind to rustc is the only way to make it generate correct unwind landing pads to implement catch_unwind. OSDK already forced this when running ktests, but not in other modes.

These changes:

  • Add -C panic=unwind in all cases. This is not ideal, but is what we want for ORPC for the moment. We may need to reevaluate this for performance.
  • Improve the panic handling and catching code to correctly pass information from the panic site to the catch site where the panic is converted to an Err. This should make error context much better and avoid silent panics within servers.

@arthurp arthurp requested a review from tewaro May 5, 2026 22:40
@arthurp arthurp marked this pull request as ready for review May 5, 2026 22:41
@arthurp arthurp requested a review from a team as a code owner May 5, 2026 22:41
@arthurp arthurp force-pushed the arthurp/better-panics branch 3 times, most recently from c96bcf6 to 86c840b Compare May 7, 2026 17:21
arthurp added 3 commits May 7, 2026 13:58
It turns out that passing -C panic=unwind to rustc is the only way to
make it generate correct unwind landing pads to implement catch_unwind
in no_std. OSDK already forced this when running ktests, but not in
other modes. This is not ideal, but is what we want for ORPC for the
moment. We may need to reevaluate this for performance in the future.

Previously, catch_unwind did not work outside of `ktest` mode. This
was deeply confusing, because code would pass unit tests, but then fail
in actual kernel runs and integration tests.
Improve the panic handling and catching code to correctly pass information
from the panic site to the catch site where the panic is converted to an
Err. This should make error context much better and avoid silent panics
within servers.
Add a kernel command line parameters `kernel.abort_on_panic` to
control if panics are caught and converted into `Err`, or if they
always abort the kernel immediately.
@arthurp arthurp force-pushed the arthurp/better-panics branch from 86c840b to dbd0b97 Compare May 7, 2026 19:00
@arthurp arthurp merged commit 301fc47 into main May 7, 2026
40 of 41 checks passed
arthurp added a commit that referenced this pull request May 7, 2026
It turns out that passing -C panic=unwind to rustc is the only way to
make it generate correct unwind landing pads to implement catch_unwind
in no_std. OSDK already forced this when running ktests, but not in
other modes. This is not ideal, but is what we want for ORPC for the
moment. We may need to reevaluate this for performance in the future.

Previously, catch_unwind did not work outside of `ktest` mode. This
was deeply confusing, because code would pass unit tests, but then fail
in actual kernel runs and integration tests.
arthurp added a commit that referenced this pull request May 7, 2026
Improve the panic handling and catching code to correctly pass information
from the panic site to the catch site where the panic is converted to an
Err. This should make error context much better and avoid silent panics
within servers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants