Skip to content

libobs: stop obs_load_core_modules reloading already loaded core modules (#2730) - #2732

Merged
zackees merged 2 commits into
masterfrom
fix/2730-core-module-reload
Oct 28, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/2730-core-module-reload

Conversation

@zackees

@zackees zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member

What and why

obs_load_core_modules() caches only success (core_modules_loaded = error.fail_count == 0), so a caller that retries after a failed call walks the core module list again. load_all_callback() skipped an already loaded module only when it was not a core module (info->type != OBS_MODULE_TYPE_CORE && existing_module != NULL), so every core module that did load was opened a second time: a second obs_module went onto obs->first_module, obs_module_set_pointer() ran again, and obs_module_load() ran again, registering the module's source/output/encoder types a second time.

The fix skips a core module that obs_get_module() already returns, with a debug log, as plugins are skipped. The success-only cache stays, so a retry still reports the failure. The two early returns in obs_open_module() (missing exports, newer libobs) also get the comment saying the library is left loaded on purpose, matching free_module() since upstream 2446f62 ("Do not call dlclose on modules", 2014); no os_dlclose is added.

RED — d502777 (test(libobs): a failed core module load must not reload the others)

New case retry_after_failure in test/cmocka/test_core_module_load.c. A new stub core_module_stub_newer.c reports LIBOBS_API_VER + 0x00010000, so the first core module in the list fails as one built for a newer libobs. The child calls obs_load_core_modules() twice and counts each core module's entries in the loaded module list.

Observed on d502777:

[==========] tests: Running 26 test(s).
core module 'decklink-captions' has 2 entries in the loaded list, want 1
[  FAILED  ] retry_after_failure
[==========] tests: 26 test(s) run.
[  PASSED  ] 25 test(s).
[  FAILED  ] tests: 1 test(s), listed below:
[  FAILED  ] retry_after_failure
 1 FAILED TEST(S)

Both calls return false (the failure is still reported); the other core modules have two entries after the second call.

GREEN — df6b3ab (libobs: skip a core module that is already loaded)

[==========] tests: Running 26 test(s).
[==========] tests: 26 test(s) run.
[  PASSED  ] 26 test(s).

Built and run in the repo's Tier 2 Docker image (obs-rust-linux-validate:1c93fce56a25553c) under xvfb-run -a, against the Tier 2 build volume. clang-format --dry-run --Werror and gersemi -c are clean. The feature behavior is documented in docs/features.md.

Tiers

  • Tier 1 (Rust unit): not applicable, the change is in C.
  • Tier 2 (C tests against libobs): test_core_module_load, 26/26 pass, including the new case. The other 25 cases (all_present, missing_dependency, missing_file, same_libobs, module search paths, names and type lists) are unchanged and pass.
  • Tier 3 (differential): not applicable, no C behavior changes against libobs-c-reference; this is a duplicate-load guard in module bookkeeping.
  • Tier 4 (protocol): not applicable.

No existing C test or public header is edited; the new test case and stub are added.

Fixes #2730

Observed output of the new case on this commit:

  [ RUN      ] retry_after_failure
  core module 'decklink-captions' has 2 entries in the loaded list, want 1
  [  FAILED  ] retry_after_failure

obs_load_core_modules() caches only success, so a caller that retries after a
failure walks the core module list again, and load_all_callback() skips an
already loaded module only when it is not a core module: every core module that
did load is opened a second time and obs_module_load() runs twice.

Refs #2730.
obs_load_core_modules() caches only success, so a caller that retries after a
failure walks the core module list again. load_all_callback() skipped an
already loaded module only when it was not a core module, so every core module
that did load was opened again, a second obs_module entry went onto
obs->first_module and obs_module_load() ran a second time, registering the
module's types again.

Skip a core module that obs_get_module() already returns, with a debug log, as
plugins are skipped. The success-only cache stays, so a retry still reports the
failure.

The two early returns in obs_open_module() also get the comment saying the
library is left loaded on purpose, which is what free_module() has done since
upstream 2446f62 ("Do not call dlclose on modules", 2014).

GREEN of test/cmocka/test_core_module_load.c's retry_after_failure: 26/26 pass.

Fixes #2730.
@zackees
zackees marked this pull request as draft October 28, 2026 05:13
@zackees
zackees marked this pull request as ready for review October 28, 2026 06:17
@zackees
zackees added this pull request to the merge queue Oct 28, 2026
@zackees

zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

CI is green (CI Gate ✅) and mergeStateStatus is CLEAN on df6b3abfb; the branch needs no rebase. RED/GREEN evidence and tier notes are in the description.

@zackees

zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

State on handoff: rebased on origin/master (0 behind, 2 commits ahead), all checks green including CI Gate ✅, PR CI is the merge gate, no local-gate stamp was needed since the PR CI run already passed in full.

Queued: position 1, state QUEUED.

Merged via the queue into master with commit 5078a29 Oct 28, 2026
39 checks passed
@zackees
zackees deleted the fix/2730-core-module-reload branch October 28, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: libobs: obs_load_core_modules loads every core module again after a failed call

1 participant