proposal(profiling-ffi): catch_unwind via global panic callback#1974
proposal(profiling-ffi): catch_unwind via global panic callback#1974r1viollet wants to merge 1 commit into
Conversation
Exploration PR — one of three sibling proposals for adding catch_unwind at the profiling FFI boundary. Routes caught panics through a globally registered C callback; the returned ProfileStatus carries a static sentinel so the return path performs no allocation on the panic side. - New panic_handler module: ddog_prof_set_panic_handler + fire_panic_handler. - New wrap_with_profile_status! macro: catch_unwind around the body, fires the registered handler (if any) on caught payloads, returns ProfileStatus::from(c"libdatadog panicked"). - Nested catch_unwind inside fire_panic_handler so OOM during message formatting cannot itself unwind. - One example migration: ddog_prof_ProfilesDictionary_insert_function. See docs/proposals/profiling-ffi-catch-unwind-callback.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
🔒 Cargo Deny Results📦
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1974 +/- ##
==========================================
- Coverage 72.63% 72.52% -0.11%
==========================================
Files 448 451 +3
Lines 73582 73756 +174
==========================================
+ Hits 53444 53491 +47
- Misses 20138 20265 +127
🚀 New features to boost your workflow:
|
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 758e03c | Docs | Datadog PR Page | Give us feedback! |
Summary
Exploration PR — one of three sibling proposals for adding
catch_unwindat the profiling FFI boundary. Not for merge as-is; intended to make the API shape concrete enough to choose between.This variant catches panics inside the FFI body and routes the panic message through a globally registered C callback. The returned
ProfileStatuscarries a static sentinelc"libdatadog panicked", so the return path performs no allocation on the panic side.panic_handlermodule:ddog_prof_set_panic_handler(cb, userdata).wrap_with_profile_status!macro:catch_unwindaround the body, fires the registered handler on caught payloads.catch_unwindinsidefire_panic_handlerso an OOM during message formatting does not itself unwind.ddog_prof_ProfilesDictionary_insert_function. OtherProfileStatus-returning functions are untouched in this PR.Full design doc:
docs/proposals/profiling-ffi-catch-unwind-callback.md.Sibling proposals
r1viollet/profiling-ffi-panic-bit— bit-flag onProfileStatus, no global state.r1viollet/profiling-ffi-panic-bit-and-callback— both, combined.Pick one (or none) of the three to take forward to a real RFC.
Test plan
🤖 Generated with Claude Code