Pass command panics to the fallback error handler#24911
Merged
Conversation
Construct a static `CommandMeta` for each type so they do not take up extra space in the buffer.
SpecificProtagonist
suggested changes
Jul 7, 2026
SpecificProtagonist
left a comment
Contributor
There was a problem hiding this comment.
Looks great; recovering as early as possible when the fallback error handler is set to swallow the panic is the right thing to do.
…field in the `CommandRunner`.
SpecificProtagonist
approved these changes
Jul 8, 2026
urben1680
suggested changes
Jul 11, 2026
| runner.local_cursor += size_of::<C>(); | ||
| #[cfg(all(feature = "debug", feature = "std"))] | ||
| { | ||
| runner.current_command_name = core::any::type_name::<C>(); |
Contributor
There was a problem hiding this comment.
I kinda wish DebugName worked like MaybeLocation where it is generic with a good default type but you could change it, like to &'static str in this case.
…ble, but move all the handling code into a `#[cold]` function so that it is not monomorphized.
urben1680
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Improve the handling of commands that panic.
Currently, if a command panics, any unapplied commands are left in the command queue. This means they will get run, but at an unpredictable time in the future.
And when running in
no_std, cleanup is not run at all and the commands simply leak.Solution
Catch panics from commands and pass them to the fallback error handler, just as we now do for systems from #24240. This means if the error handler is set to something non-panicking like
warn, thenflush_commands()will never panic and all commands in the queue will be applied.Introduce a RAII guard during command application that will drop any commands still in the queue and perform cleanup during unwinding, even on
no_std.To make the command's type name available in the error handler, add a field to the RAII guard that gets written by
consume_command_and_get_sizebefore applying the command.