pk_init missing catch_panic wrapper: panic UB + stale error state
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Search the provekit-ffi sources for pk_init and the existing catch_panic wrapper used by other FFI functions. Confirm that initialization clears the prior error state and prevents register_ntt() panics from crossing the extern "C" boundary, then run the relevant FFI tests if available.
Written by the indexing model from the issue text.
Description
Nearly every FFI function in provekit-ffi wraps its body in catch_panic(), which:
- Calls
clear_last_error()at entry - Catches any Rust panic before it unwinds across the
extern "C"boundary
But pk_init is the only function that skips this:
pub extern "C" fn pk_init() -> c_int {
provekit_common::register_ntt(); // no catch_panic
PKStatus::Success.into()
}
This has two major consequences:
-
Undefined behaviour on panic:
- If
register_ntt()panics, the panic may unwind through the extern "C" boundary, causing undefined behaviour in C, which can result in app (iOS/Android) crashes or silent memory corruptions with no recoverable error code.
- If
-
Stale error state after successful init:
- Since
clear_last_error()is never called, any error set by a previous failing FFI call persists afterpk_init()returns success. So,pk_get_last_error()after successfulpk_init()may show a stale error message from an unrelated failure.
- Since
- Dominant language
- Noir
- Stars
- 138
- Forks
- 47
- Avg merge
- 1d 34m
- Merged PRs (30d)
- 6
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.
More from worldfnd/provekit
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in worldfnd/provekit
Similar issues
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100