obsproject / obsproject/obs-studio

Settings window crashes (segfault) the app when there are no outputs

Open
#12,843 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
76.4k
Forks
10.2k
Avg merge
4d 23h
Merged PRs (30d)
12

Description

Operating System Info

Other

Other OS

Linux

OBS Studio Version

32.0.2

OBS Studio Version (Other)

No response

OBS Studio Log URL

N/A

OBS Studio Crash Log URL

No response

Expected Behavior

The app should not crash.

Current Behavior

The app crashes.

Steps to Reproduce
  1. Open the settings window when there are no outputs in the system.
Anything else we should know?

I debugged it and found the problem.

Backtrace:

#0  __strcmp_evex () at ../sysdeps/x86_64/multiarch/strcmp-evex.S:320
#1  0x00007ffff67b2fbc in find_output (id=0x0) at /usr/src/debug/obs-studio/obs-studio-32.0.2/libobs/obs-output.c:126
#2  obs_get_output_supported_video_codecs (id=0x0)
    at /usr/src/debug/obs-studio/obs-studio-32.0.2/libobs/obs-output.c:3296
#3  0x00005555557e9136 in OBSBasicSettings::ResetEncoders (this=0x7fffffffbee0, streamOnly=false)
    at /usr/src/debug/obs-studio/obs-studio-32.0.2/frontend/settings/OBSBasicSettings_Stream.cpp:1604
#4  0x000055555583a615 in OBSBasicSettings::LoadOutputSettings (this=0x7fffffffbee0)
    at /usr/src/debug/obs-studio/obs-studio-32.0.2/frontend/settings/OBSBasicSettings.cpp:2165
#5  OBSBasicSettings::LoadSettings (this=0x7fffffffbee0, changedOnly=false)
    at /usr/src/debug/obs-studio/obs-studio-32.0.2/frontend/settings/OBSBasicSettings.cpp:2918
#6  0x0000555555827f57 in OBSBasicSettings::OBSBasicSettings (this=<optimized out>, parent=<optimized out>, 
    this=<optimized out>, parent=<optimized out>)
    at /usr/src/debug/obs-studio/obs-studio-32.0.2/frontend/settings/OBSBasicSettings.cpp:828
#7  0x00005555558ed0d4 in OBSBasic::on_action_Settings_triggered (this=0x555555fdda80)
    at /usr/src/debug/obs-studio/obs-studio-32.0.2/frontend/widgets/OBSBasic_MainControls.cpp:206

It crashes because the find_output function does not check its input id parameter for null.

https://github.com/obsproject/obs-studio/blob/c025f210d36ada93c6b9ef2affd0f671b34c9775/libobs/obs-output.c#L122-L130

The following patch fixes the problem:

--- a/libobs/obs-output.c
+++ b/libobs/obs-output.c
@@ -121,6 +121,9 @@
 
 const struct obs_output_info *find_output(const char *id)
 {
+	if (id == NULL)
+		return NULL;
+
 	size_t i;
 	for (i = 0; i < obs->output_types.num; i++)
 		if (strcmp(obs->output_types.array[i].id, id) == 0)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with find_output in libobs/obs-output.c and follow the reported path through obs_get_output_supported_video_codecs and OBSBasicSettings::ResetEncoders in frontend/settings/OBSBasicSettings_Stream.cpp. Reproduce opening Settings with no system outputs and verify the application no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
desktop
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.