Repository navigation
Description
Summary
panic = "abort" is set only for [profile.release] in the workspace
Cargo.toml, but libobs/cmake/rust.cmake calls
corrosion_import_crate(MANIFEST_PATH "${CMAKE_SOURCE_DIR}/Cargo.toml" CRATES libobs-rust CRATE_TYPES staticlib)with no PROFILE. Per Corrosion's documented behaviour: "If you do not specify a
profile ... corrosion will select the standard dev profile if the CMake
config is either Debug or unspecified. In all other cases the release profile is
chosen for cargo."
CMAKE_BUILD_TYPE is empty unless the user passes -DCMAKE_BUILD_TYPE=..., so
the default cmake -S . -B build && cmake --build build links libobs against a
dev-profile staticlib where panic = "unwind". In that configuration a panic
in any #[unsafe(no_mangle)] pub unsafe extern "C" shim unwinds across the C
ABI, which is undefined behaviour (typically a std::thread panic hook followed
by an abort, but the unwinding itself is UB and on Windows SEH can turn it into
an unhandled exception).
Current exposure
I audited the whole merged Rust surface (rust/obs-util, rust/obs-graphics,
rust/libobs-rust) and no panic is reachable through the C ABI today, so
this is a latent hazard rather than a live crash:
Mutex::lock()is used poison-tolerantly everywhere
(rust/obs-util/src/ffi/base.rs:53unwrap_or_else(|err| err.into_inner())),
so a poisoned handler mutex cannot panic a later call.- The only two panic sites in
src/are both off the C path:rust/obs-util/src/base.rs:117expect("ascii warning")— inside the safe
coreLogger, not the FFI shim (the shim uses theCRASH_HANDLER_ALREADY_SET
CStrconstant directly).rust/obs-util/src/darray.rs:132assert!(start <= self.items.len())— in
DArray::find;darray_findhas no#[unsafe(no_mangle)]shim
(rust/obs-util/src/ffi/darray.rsexports nothing).
- Every shim uses
.get()(not indexing) orResult-based I/O and
wrapping_*arithmetic where C wraps, so there is no arithmetic or slice-limit
panic.Mutex<State>inffi/base.rsis the only shared state.
Why it matters
The guard is load-bearing for future ports, not just this one: the testing policy
and the comment in Cargo.toml both rely on "panics cannot unwind across the C
ABI". The next port that adds a single unwrap(), slice index or expect() in a
shim turns a bad argument or a full disk into UB in the default build
configuration, while every release-configuration CI run stays green — so CI
would not catch it.
Suggested fix
Pin the profile so the staticlib is always built with the abort strategy, e.g.
corrosion_import_crate(
MANIFEST_PATH "${CMAKE_SOURCE_DIR}/Cargo.toml"
CRATES libobs-rust
CRATE_TYPES staticlib
PROFILE release
)or, if a debug-plumbing staticlib must be possible, gate a -Cpanic=abort
rustflag on the non-test profile. A one-line comment in rust.cmake recording
why the profile is pinned would keep the next person from "simplifying" it away.
Verification note
soldr cargo test --workspace --locked is green at origin/master
(75667ce45), which only exercises the dev-profile test harness and says
nothing about the staticlib.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(libobs): build the Rust staticlib with the release profile
chriscoveries commentedon Oct 10, 2026
Closed as fixed: PR #81 pins
PROFILE releaseoncorrosion_import_crate(libobs/cmake/rust.cmake:14-18), so the staticlib is always built with[profile.release] panic="abort"regardless ofCMAKE_BUILD_TYPEbeing Debug, RelWithDebInfo or unset.