Repository navigation
obs-core: Port the module list calls - #4467
Merged
Merged
Conversation
rdoupe
force-pushed
the
fix/rust-port-port-the-module-list-c-734
branch
from
November 10, 2026 05:06
a5fc2e5 to
ae05b80
Compare
7 tasks
Tier 1 tests for obs_core::module_lists, the module list calls of libobs/obs-module-lists.c.h, against a todo!() core over a model core. The first eight port test_module_lists' cases one to one: the calls with no core, the log with no loaded module, the type lists with and without a module, the file and config path lookups, the search path and safe and disabled name lists, and the NULL id. The rest pin the order of the reads, every loaded module in the log, and the one intentional difference: obs_log_loaded_modules() with no core logs nothing, where the C crashes on the core's first module. Proptests cover when each list is pushed to. Refs #4465.
The safe core of libobs/obs-module-lists.c.h: log_loaded_modules() (obs_log_loaded_modules()), add_type() (obs_module_add_source() and its output, encoder and service siblings), find_file() (obs_find_module_file()), config_path() (obs_module_get_config_path()), add_module_path() (obs_add_module_path()) and add_name() (obs_add_safe_module() and obs_add_disabled_module()). The core and its modules are the caller's Lists: each read, log line and push is one call of it, in the C's order and under the C's conditions, and none takes a lock. The paths come from the cores that are already Rust, module_paths::find_file() and module_names::config_path(). One intentional difference: with no core, log_loaded_modules() logs nothing and returns, where the C logs the heading and then crashes reading the core's first module. Refs #4465.
The C ABI of obs_core::module_lists: the ten module list calls, EXPORT in obs.h, so libobs exports the shims under their names (rust-exports.d). Every field and list of the core and of a module goes through the module list seam, so nothing mirrors struct obs_core or struct obs_module; struct obs_module_path, the entry of the core's search paths, is the one mirror. Each copy is a bmalloc'd bstrdup(), one allocation as in the C, since the lists' owners bfree() them, and each push is obs-util's darray_push_back() with the typed list's element size. A NULL id pushes a NULL entry, as before. The log lines go to blog() with the C's format strings. obs-module-lists.c.h moves from libobs.core into its own ported group, libobs.ported-module-lists, so hybrid libobs links the Rust calls and the C reference keeps the C. test_module_lists and test_module_lists_seam see the swap through the hybrid libobs. obs_log_loaded_modules() with no core (before obs_startup() or after obs_shutdown()) now logs nothing, where it crashed reading the core's first module. Refs #4465.
Tier 3 for obs_core::ffi::module_lists: the original obs-module-lists.c.h, compiled as oracle_obs_* with the module list seam under its own names over a thread-local stand-in core, against the shims on two copies of the same world (a core or none, its module config path, modules with their files, data paths and names, some loaded). blog() is the oracle's recording stand-in on both sides. After every call it compares the result and the log, and at the end every list of the core and of each module: entries (NULL against empty included), sizes and capacities, and the search paths' type. It runs test_module_lists' calls in its order and proptests over random worlds and calls; the file lookups run on a directory of the test's own. A layout test checks struct obs_module_path against the C. The intentional difference, obs_log_loaded_modules() with no core, is left out of the comparison (the C crashes) and pinned on the Rust side. Mutants of the search path check, the log order and heading, the data path read, the type and name lists, the search path's type, the id copy, the list growth, the config path read and the name copy each fail it. Refs #4465.
The rust/README.md rows (obs-core's and the new module_lists row), naming.md's obs-core row, and the obs-core description and module docs for libobs/obs-module-lists.c.h, over the module list seam. One intentional difference: obs_log_loaded_modules() with no core logs nothing. Fixes #4465.
The C reads each string argument of the module list calls only past its guard: obs_module_add_*()'s id only for a module (bstrdup(id)), obs_find_module_file()'s and obs_module_get_config_path()'s file only for a module, obs_add_module_path()'s paths only with a core and neither NULL (a NULL test reads nothing), and the safe and disabled names only with a core. The shims read every string before the core checks its guard, so an ignored pointer is dereferenced. Tier 1 tests for deferred-read versions of the calls, whose string arguments are readers called only past the guard, against todo!() stubs: they count which strings each call reads and in what order. Refs #4465.
The deferred-read calls: add_type_deferred() reads the id only for a module, find_file_deferred() and config_path_deferred() the file only for a module (after the module's data path, and its config path and name), add_module_path_deferred() the binary path and then the data path only with a core and neither NULL, and add_name_deferred() the name only with a core. The calls on plain strings now wrap them. The shims pass each C string as a reader whose NULL test reads nothing, so a pointer a call ignores is never dereferenced, as in the C. ignored_strings_are_not_read gives both sides an unreadable non-NULL pointer for every argument a call ignores; the shims before this faulted on it. Refs #4465.
The parity test turned the logs and the list state into text with String::from_utf8_lossy(), while its ids, names, files and paths are any bytes but NUL, so two different bytes past 0x7f both became the replacement character and compared equal. It now compares the raw bytes. A mutant that rewrites every id byte past 0x7f to 0xff, which the text comparison let through, fails it. Test only; no change to the port. Refs #4465.
The module_lists row of rust/README.md now says each string argument is read only past the guard the C reads it after. Fixes #4465. Local-Gate: v1 tree=c75f335a234e392e0dce7cac0f0f8c05373afb91 secs=2454 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1794293152,"gate":"rust/all/fmt","host":"linux-x86_64","key":"2d758203b9995b718d44985742efe7fe3db36e929fbf8fde0433e602b3fb6dbc","lane":"lint","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":150,"stamp":"0ca43b53a584bc65b01c2742a88c6143","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"} Ci-Attestation: {"at":1794293152,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"2d758203b9995b718d44985742efe7fe3db36e929fbf8fde0433e602b3fb6dbc","lane":"lint","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":150,"stamp":"ac377dcb0e80c22810ac73c8bfeecf18","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"} Ci-Attestation: {"at":1794293152,"gate":"rust/x86_64-unknown-linux-gnu/dylint","host":"linux-x86_64","key":"425944b9b42d0641977a93792f7105ae3c0c2e0aa97ba88e3be2d6fbdbeb1074","lane":"dylint","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":14,"stamp":"b3983f986c55466d6740c0761ebc7cac","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"} Ci-Attestation: {"at":1794293152,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"5b25834c8c05e66f082fc5a14751566c6afc68b01e32c17c9999c3b4e6937075","lane":"rust-test","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":219,"stamp":"b508c007c94c4cfaa2f3ca9fa5bd59f0","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"} Ci-Attestation: {"at":1794293152,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"ea429209ddb6ca5d1925bd3c78ce17e2b78718dbdd799d1b753cff8ec3bf269f","lane":"cross","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":226,"stamp":"485e0617296d4ff12936f15d69c7c129","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"} Ci-Attestation: {"at":1794293152,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"ea429209ddb6ca5d1925bd3c78ce17e2b78718dbdd799d1b753cff8ec3bf269f","lane":"cross","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":226,"stamp":"655e1fb751c8f132859e19c98803d75f","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"} Ci-Attestation: {"at":1794293152,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"ea429209ddb6ca5d1925bd3c78ce17e2b78718dbdd799d1b753cff8ec3bf269f","lane":"cross","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":226,"stamp":"5d8d6a10b327832a5211e7ceb400329d","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"} Ci-Attestation: {"at":1794293152,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"ea429209ddb6ca5d1925bd3c78ce17e2b78718dbdd799d1b753cff8ec3bf269f","lane":"cross","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":226,"stamp":"58ebb8fa8dee09a6023b9db91d51776c","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"} Ci-Attestation: {"at":1794293152,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"735caed43d6dbae66e9c09b0faa71896e62bd140926fdb50f4ba524bc0005eb0","lane":"tier2-linux","parents":["9da0eb985e26af452577f70ee07c1e8709efcd8c"],"secs":2454,"stamp":"372d6d4029c39e105e2f202cece55244","tree":"c75f335a234e392e0dce7cac0f0f8c05373afb91","v":1,"via":"run"}
rdoupe
force-pushed
the
fix/rust-port-port-the-module-list-c-734
branch
from
November 10, 2026 06:46
ae05b80 to
60e9df4
Compare
rdoupe
marked this pull request as ready for review
November 10, 2026 07:27
Collaborator
Author
|
Handed off to the coordinator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4465
What and why
Ports the module list calls (
libobs/obs-module-lists.c.h, extracted in #4139) torust/obs-core, new modulemodule_lists:obs_log_loaded_modules(),obs_module_add_source(),_add_output(),_add_encoder(),_add_service(),obs_find_module_file(),obs_module_get_config_path(),obs_add_module_path(),obs_add_safe_module()andobs_add_disabled_module(). All ten areEXPORTinobs.hand keep their names.todo!()core over a model core. The first eight porttest_module_lists' cases one to one; the rest pin the order of the reads, every loaded module in the log, and the one intentional difference.Lists). Each read, log line and push is one call of it, in the C's order and under the C's conditions. The paths come from the cores that are already Rust (module_paths::find_file,module_names::config_path).struct obs_coreorstruct obs_module; the one mirror isstruct obs_module_path, with a layout test. The copies arebmalloc'd (bstrdup(), as the lists' ownersbfreethem) and the pushes are obs-util'sdarray_push_back()with each list's element size.obs-module-lists.c.hmoves fromlibobs.coreinto its own ported group, so hybrid libobs runs the Rust and the C reference keeps the C.ignored_strings_are_not_readhands both sides an unreadable non-NULL pointer for every ignored argument; the shims before the fix fault on it.Intentional difference (a fix):
obs_log_loaded_modules()read the core's first module without checking the core, where the calls beside it check it, so an embedder, plugin or script that called it beforeobs_startup()or afterobs_shutdown()crashed on a NULL read. The port returns without logging when there is no core. It is listed in the parity test header and inrust/README.md, the parity test leaves out exactly that call, and a Rust-side test pins it.Kept as the C has it: a NULL id is pushed as a NULL entry, and
obs_module_get_config_path()reads the core's config path without checking the core. No call takes a lock, as none did.The round's check of the encoder registration's short-structure
capsread needed no change: it is covered bytest_encoder_short_scaling_caps(test/cmocka/test_register_short_info.c) andtest_encoder_sizes(obs_core::module_register_copy).(no upstream issue)
RED → GREEN
obs-core: Test the module list calls port):soldr cargo test -p obs-data --locked --test obs-tests-core module_listsfails 16 of 16 withnot yet implemented.obs-core: Test the module list string reads):type_id_read_only_with_module,path_file_read_only_with_module,module_paths_read_only_past_the_checksandnames_read_only_with_corefail withnot yet implemented; the other 16 pass. GREEN: ce8a7e7.obs_core::module_lists, 20/20.obs_core::module_lists_parity, 6/6, byte for byte: every result, log line and list (entries, NULL against empty, sizes and capacities, the search paths' type) compared with the original file overtest_module_lists' calls, the log with NULL files, NULL config paths and names, and proptests over random worlds and calls, plus thestruct obs_module_pathlayout, and an unreadable pointer for every argument a call ignores. Mutants of the search path check, the log order, the heading, the data path read, the type and name lists, the search path's type, the id copy, the list growth, the config path read and the name copy each fail it, as does one that rewrites id bytes past 0x7f (12 of 12).test_module_lists,test_module_lists_seam,test_core_module_load,test_register_short_infoandtest_module_register_copy_steps: 5/5 on the C build, hybrid libobs andlibobs-c-reference, 0 skipped.t), and hybrid libobs compiles no C for the new group../lint;./unittest(host tests 7773/7773 with 6 skipped and 914/914, Docker Tier 2 858/858 on both libobs builds);--lane lint,--lane dylint,--lane cross, the Windows MSVCclippy --all-targets,ci/windows_link_check.pyand theport_comparisonbench test all pass. The head is stamped by the local gate (lint, dylint, rust-test, cross and tier2-linux run).Test cost: new tests: 26 (20 Tier 1, 6 Tier 3), about 0.02 s together, peak RSS 12.3 MB over 20 runs with
OBS_PARITY_CASES=reduced, no threads of their own; generated strings are capped at 8 bytes, worlds at 4 modules and 24 calls.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)