Repository navigation
fix(libobs): only destroy the audio mutexes obs_init_audio created (#2910) - #2911
Conversation
) The Windows Tier 2 lane segfaults in this group: obs_reset_audio2(NULL) reaches obs_free_audio() before obs_init_audio() ever ran, and it destroys two mutexes that were never initialised. glibc tolerates that; the Windows pthread layer does not, so the failure is only visible in the Windows job cited on the issue. This case pins the behaviour the fix must keep: the null reset is a success on a cold core, twice, then a real reset works and the cold reset succeeds again.
…2910) obs_free_audio() ran pthread_mutex_destroy on a core that was never opened, so obs_reset_audio2(NULL) before the first successful obs_reset_audio2(info) destroyed zeroed memory. Linux's glibc makes that a no-op; on Windows it faulted and took the whole cmocka group down (build(cmake) lane job 123456184550). obs_init_audio() now records that both mutexes exist, and obs_free_audio() destroys them only then. It also destroys the monitoring mutex if the task mutex fails to initialise, instead of leaking it. A real open still frees both in obs_shutdown.
|
The PR's own CI does not select the lane this fixes: Evidence run: |
|
GREEN on the lane that fails. The
That is the same job that fails on master in Marking ready and queueing. |
|
Windows Tier 2 is green on this branch. Run 40879828636 ( It passed in all four native-core passes of the job (327/327 each), and the new Also green on the PR itself: Handed off to the coordinator — it is in the merge queue (position 1, |
Fixes #2910.
What changed
obs_free_audio()destroyedtask_mutexandmonitoring_mutexunconditionally, but onlyobs_init_audio()creates them.obs_reset_audio2(NULL)frees before it looks at the info (libobs/obs.c.h:1621), so a reset on a core that was never opened destroyed zeroed memory.struct obs_core_audiogainsmutexes_initialised(libobs/obs-internal.h), set byobs_init_audio()only after both mutexes exist.obs_free_audio()destroys them only when that flag is set; it also clears the flag via the existingmemset, so a later open re-arms it.obs_init_audio()now destroys the monitoring mutex when the task mutex fails to initialise, instead of leaking it.No behaviour change for a normal open/close: both mutexes are created and destroyed exactly as before whenever audio was opened.
RED — the Windows Tier 2 lane, job
123456184550There is no Linux-side RED for this: glibc makes
pthread_mutex_destroyon a zeroed mutex a no-op, soRust Tier 2 Linux 🐧 (tests ON)passes on master. The failure only exists on the Windows pthread layer, which is the lane#2881's own PR skipped:The first statement of
test_reset_audio_ticksisassert_true(obs_reset_audio2(NULL)), and every test that passes in that group is one that never callsobs_reset_audio2(). The job isBuild 🧱 / Rust Tier 2 (windows-2025-vs2026)in run 40875411169, on a PR whoselibobs/andtest/cmocka/test_core_setup_rules_steps.care identical to master (git diff origin/master <head> -- libobs test/cmocka/test_core_setup_rules_steps.cis empty).Commit
eb56094bc(test(core): pin a reset with no info on a never-opened audio core) addstest_reset_audio_coldas the first case of thecallersgroup: a null reset twice on the cold core, then a real reset that must succeed, then a cold reset again. It passes on Linux before and after the fix — it pins the behaviour the fix has to keep (the crash must not be "fixed" by rejecting the null reset), not a Linux-visible regression.GREEN —
56853180cninja -C build libobsbuilds clean;./lint --fixis ok (47.2 s). The Windows lane on this PR is the GREEN evidence and is what I am watching; this PR is a draft until it is green.No
docs/features.mdline: internal lifetime fix, nothing user-visible.