forked from 1b-agent/opencadstudio-upstream
fix(plugin): f64 pick coords + harden out-of-process lifecycle
Follow-ups after merging the out-of-process plugin isolation work: - Convert the out-of-process interactive adapter's `on_point` / `on_entity_pick` to `glam::DVec3`, matching the `CadCommand` trait, which moved to f64 pick coordinates. The branch predated that change and no longer compiled against the trait. - Contain plugin constructor panics in `export_plugin!`: the constructor runs across the C ABI boundary in `ocs_plugin_register`, where an unwinding panic is undefined behavior. Catch it and return null, which the loader already treats as a failed registration. - Reap killed runner processes. The spawn-timeout and disconnect paths called `child.kill()` without `wait()`, leaving a zombie on Unix until the host exited. Route both — and `shutdown()` — through a shared `reap()` that kills and waits on a detached thread. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
deec2a8fd3
commit
b4093724f2
4 files changed
+220
-18
No files matched your search
@@ -97,9 +97,18 @@ macro_rules! export_plugin {
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ocs_plugin_register(
|
||||
) -> *mut ::std::boxed::Box<dyn $crate::host::BuiltinPlugin> {
|
||||
let plugin: ::std::boxed::Box<dyn $crate::host::BuiltinPlugin> =
|
||||
::std::boxed::Box::new($ctor);
|
||||
::std::boxed::Box::into_raw(::std::boxed::Box::new(plugin))
|
||||
// The constructor runs across a C ABI boundary; a panic unwinding
|
||||
// past it is undefined behavior. Contain it and report failure as a
|
||||
// null pointer, which the host loader treats as "registration
|
||||
// failed" rather than crashing the runner process.
|
||||
match ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| {
|
||||
let plugin: ::std::boxed::Box<dyn $crate::host::BuiltinPlugin> =
|
||||
::std::boxed::Box::new($ctor);
|
||||
::std::boxed::Box::into_raw(::std::boxed::Box::new(plugin))
|
||||
})) {
|
||||
::std::result::Result::Ok(ptr) => ptr,
|
||||
::std::result::Result::Err(_) => ::std::ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user