linksplatform / linksplatform/doublets-rs
Wrap all exported functions to catch and unwind
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6
- Forks
- 0
- Avg merge
- 1h 37m
- Merged PRs (30d)
- 1
Description
All panics must be catch and unwind otherwise it is UB.
I recommend use catch_unwind with the following if let:
let result = panic::catch_unwind(|| {
// ffi function call
});
if let Err(err) = result {
// if `err` panic in `Drop` we will be sad
forget(err);
}
You can create macro or function to resolve it
In currently implementation:
#[ffi::specialize_for(
. . .
)]
unsafe fn drop_links<T: LinkType>(this: *mut c_void) {
let links: &mut WrappedLinks<T> = unnull_or_panic(this);
drop_in_place(links);
}
We can split to:
unsafe fn drop_links_impl<T: LinkType>(this: *mut c_void) {
// impl
}
#[ffi::specialize_for(
. . .
)]
unsafe fn drop_links<T: LinkType>(this: *mut c_void) {
catch_unwind(/* some */)
}
Or add this behavior to ffi::specialize_for
Contributor guide
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 by locating the exported FFI functions and the existing drop_links implementation that calls unnull_or_panic and drop_in_place. Compare wrapping each implementation with panic::catch_unwind against adding the behavior to ffi::specialize_for. Done means exported functions catch panics and safely discard panic payloads without changing their FFI behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100