Skip to content

bug: test_core_setup_rules_steps segfaults in the Windows Tier 2 lane, so master's Windows gate is red (#2881) #2910

Closed

Description

@zackees

Build 🧱 / Rust Tier 2 (windows-2025-vs2026) is red on master code. Every PR that selects that lane now fails on test_core_setup_rules_steps for a reason unrelated to its own diff.

Evidence

Job 123456184550 of run 40875411169, on PR #2906 — a diff that touches only shared/file-updater/file-updater/curl-accept-encoding.h, two cmocka files and CMakeLists.txt. git diff origin/master <that head> -- test/cmocka/test_core_setup_rules_steps.c libobs is empty, so this is master's code:

142/327 Test #145: test_core_setup_rules_steps ....................***Failed    0.04 sec
[==========] callers: Running 7 test(s).
[       OK ] test_reset_video_gates
[  ERROR   ] --- Test failed with exception: (11)
[  FAILED  ] test_reset_audio_ticks
[       OK ] test_cmdline_once
[       OK ] test_latest_input_type
[  ERROR   ] --- Test failed with exception: (11)
[  FAILED  ] test_monitoring_device
[       OK ] test_frame_counts_without_mix
[       OK ] test_find_data_file_order
[  ERROR   ] --- Test failed with exception: (11)
[  FAILED  ] GROUP TEARDOWN
 2 FAILED TEST(S)

99% tests passed, 1 tests failed out of 327
	145 - test_core_setup_rules_steps (Failed)              native-core

exception: (11) is SIGSEGV. The steps group passes in full (12/12), so the crash is confined to the group that starts a real core (group_setup → obs_startup).

Why it reached master

#2881 introduced this test, and its own PR run never exercised the lane:

$ gh pr view 2881 --json statusCheckRollup
Build 🧱 / Rust Tests 🦀 (windows-2025-vs2026)	SKIPPED
Build 🧱 / Rust Tier 2 (windows-2025-vs2026)	SKIPPED
CI Gate ✅	SUCCESS

Master's push runs skip Windows Tier 2 as well, so the lane's first real exercise is an unrelated PR that selects it — which is what #2906 hit.

Where it crashes (read from the code; not a stack trace)

Both failing tests call obs_reset_audio2() from a cold audio core, and it is the first thing test_reset_audio_ticks does:

static void test_reset_audio_ticks(void **state)
{
	SKIP_WITHOUT_OBS();
	assert_true(obs_reset_audio2(NULL));   /* test_core_setup_rules_steps.c:409 */

obs_reset_audio2() calls obs_free_audio() before it validates oai (libobs/obs.c.h:1610), and obs_free_audio() unconditionally destroys two mutexes:

	pthread_mutex_destroy(&audio->task_mutex);
	pthread_mutex_destroy(&audio->monitoring_mutex);
	memset(audio, 0, sizeof(struct obs_core_audio));

Those mutexes are initialised only in obs_init_audio(), i.e. only after audio was successfully opened. A reset with oai == NULL before that therefore destroys zeroed memory. Linux's glibc pthread_mutex_destroy on a zeroed mutex is harmless, which is why Rust Tier 2 Linux (tests ON) passes on the same commit; on Windows libobs links a pthreads-win32 layer where the same call can fault, and GROUP TEARDOWN (obs_shutdown → obs_free_audio again) reports the same exception 11.

Not verified: there is no Windows host here, so this is code reading, not a debugger stack. A cdb/dump trace of the failing binary would confirm the frame.

Acceptance criteria

  • test_core_setup_rules_steps passes in Build 🧱 / Rust Tier 2 (windows-2025-vs2026), and Build 🧱 / Rust Tier 2 Linux 🐧 (tests ON) still passes.
  • obs_free_audio() is safe when the audio core was never opened: destroy only mutexes that obs_init_audio() initialised (an explicit initialised flag, or an early return when audio->audio == NULL and no init has happened) — not by deleting the obs_reset_audio2(NULL) case, which the test pins as a success.
  • No behavior change for the normal obs_shutdown after a real audio open.
  • A regression test is not required on Linux for this fix: the failure is Windows-only, so the Windows lane is the RED → GREEN evidence and the PR body should say so.

No docs/features.md line: internal lifetime fix, no user-visible behavior.

Activity

  1. added
    bug
    P0
    size:S
    on Oct 29, 2026
  2. zackees commented on Oct 29, 2026

    @zackees
    MemberAuthor

    Claiming: #2910 — make obs_free_audio() safe when the audio core was never opened.

    1. RED: a Linux cmocka case that pins the invariant the Windows crash exposes — obs_reset_audio2(NULL) before any successful obs_reset_audio2(info) returns true and leaves the core reusable (it must not depend on destroying uninitialised mutexes). It passes on Linux today, so the RED evidence for this issue is the Windows job 123456184550, quoted in the body; the Linux case is the characterization that keeps the fix honest.
    2. GREEN: track whether obs_init_audio() initialised the mutexes and destroy them only then, so obs_free_audio() is idempotent for a cold core. obs_shutdown after a real audio open is unchanged.
    3. Evidence: Build 🧱 / Rust Tier 2 (windows-2025-vs2026) green plus Rust Tier 2 Linux 🐧 (tests ON) green on the PR; no docs/features.md line (internal lifetime fix).

    First PR: within this tick, work in this checkout (~/dev/obs-rust/obs-studio5), branch fix/2910-free-audio-cold-core.

  3. zackees commented on Oct 29, 2026

    @zackees
    MemberAuthor

    Closing note: what fixed it, and what is left.

    Fix — a32bad067 (PR #2911). struct obs_core_audio carries mutexes_initialised, set by obs_init_audio() only after both mutexes exist; obs_free_audio() destroys them only when it is set, and the existing memset clears it so a later open re-arms it. obs_init_audio() now also destroys the monitoring mutex when the task mutex fails, instead of leaking it.

    Evidence — the Windows Tier 2 lane, which this PR's own scope does not select, run on demand: scheduled.yaml dispatch on the branch, run 40879828636, job 123474622500 → success, 100% tests passed out of 327, test_core_setup_rules_steps passed in all three repeats. Locally the same tree passed the full gate (lint, rust-test 523 s, cross 243 s, tier2-linux 2507 s, 610/610 cmocka in the container).

    Left over — the scope rule that let this class through: nothing in ci/ci_scope.py puts a libobs/-only diff in the Windows lane, so a Windows-only crash is unobservable from the PR that causes it. Filed as #2916 with the three options and the cost of each.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0bugsize:S

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions