Skip to content

bug: libobs: level getters and texture checks crash with no core #2566

Closed

Description

@rdoupe

Location

libobs/obs.c.h, on master at 0e53b9f:

float obs_get_video_sdr_white_level(void)
{
	struct obs_core_video *video = &obs->video;
	return video->graphics ? video->sdr_white_level : 300.f;
}

float obs_get_video_hdr_nominal_peak_level(void)
{
	struct obs_core_video *video = &obs->video;
	return video->graphics ? video->hdr_nominal_peak_level : 1000.f;
}

bool obs_get_audio_info(struct obs_audio_info *oai)
{
	struct obs_core_audio *audio = &obs->audio;
	...
	if (!oai || !audio->audio)
		return false;

bool obs_nv12_tex_active(void)
{
	const obs_canvas_t *canvas = obs->data.main_canvas;
	...
}

bool obs_p010_tex_active(void)
{
	const obs_canvas_t *canvas = obs->data.main_canvas;
	...
}

(lines 1650-1660, 1682-1695 and 3406-3418.)

Class

NULL pointer dereference (crash) before obs_startup or after obs_shutdown.

How it is reached

obs_get_video_info returns false when there is no core (#1509), but these five getters read through the global obs without checking it. With no core (before obs_startup, or after obs_shutdown, which sets obs to NULL), each one dereferences NULL: obs->video.graphics, obs->audio.audio or obs->data.main_canvas. #2253 guarded the two texture checks only for a main canvas with no mix, not for no core at all.

A plugin, script or headless tool that calls one of them outside the core's lifetime crashes, where obs_get_video_info gives the "no video" answer. obs_get_audio_info2 calls obs_get_audio_info first, so it crashes the same way.

No upstream issue.

Proposed fix and failing test

The #1509 pattern: with no core, each returns its existing "no video/audio" answer and nothing else changes:

  • obs_get_video_sdr_white_level: 300
  • obs_get_video_hdr_nominal_peak_level: 1000
  • obs_get_audio_info: false, oai untouched (so obs_get_audio_info2 returns false too)
  • obs_nv12_tex_active, obs_p010_tex_active: false

Test (RED first): a cmocka test that never calls obs_startup and calls each getter, each in its own case so one crash doesn't hide the others. RED: each case crashes with SIGSEGV. GREEN: the defaults above, with the out-structs left as they were.

Activity

  1. added
    bug
    on Oct 27, 2026
  2. rdoupe commented on Oct 27, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2566.

    1. RED: a cmocka test that calls the five getters (and obs_get_audio_info2) with no core, one case each; each crashes on master.
    2. GREEN: the bug: util: os_generate_formatted_filename uses video info that obs_get_video_info did not fill #1509 guard in each, returning 300, 1000, false, false, false with no core, nothing else changed.

    PR expected today.

  3. added
    ready
    on Oct 27, 2026
  4. rdoupe commented on Oct 27, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by the PR that guards the level and texture getters (#2569), merged as 3bddf1b. With no core (before obs_startup() or after obs_shutdown()), obs_get_video_sdr_white_level() returns 300, obs_get_video_hdr_nominal_peak_level() returns 1000, obs_get_audio_info() (and so obs_get_audio_info2()) returns false with the out-struct untouched, and obs_nv12_tex_active() / obs_p010_tex_active() return false. Nothing changes while the core exists. The new test_no_core_getters covers each getter in its own case.

    Left: nothing for this bug, so there is no follow-up issue. The test checks the never-started case only; after obs_shutdown() the getters take the same no-core branch.

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

Metadata

Metadata

Assignees

Labels

bugready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions