Add a std::panic::propagate function to pair with std::panic::recover
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
Say we're integrating with a C API where the control flow will pass from Rust to C and then back into Rust. If the inner Rust code panics, we have to stop that panic from unwinding through the C layer. std::panic::recover will allow us to do this. But now we would ideally want to carry the panic payload through the C layer and "restart" unwinding when we're back in Rust-land. We can just panic!(payload), but that will rerun the panic handler function, printing the "thread foo panicked" an extra time. This situation becomes a bit more unfortunate with custom panic handlers, since those handlers may do more expensive tasks than just printing a message.
To solve this, we could add a function which acts like panic!() but does not run the panic hander. Since we already have the payload, a normal function taking a Box<Any + Send> will suffice rather than a macro.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's description of std::panic::recover and the proposed std::panic::propagate API, then inspect the Rust standard-library panic implementation. Done means carrying a Box<Any + Send> across a C boundary and resuming unwinding without invoking the panic handler a second time.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100