Repository navigation
libobs: Name the requested name in the rename warning, and take a NULL rename - #1804
Merged
Merged
Conversation
The rename warning of obs_context_data_setname_ht() names the old name as the duplicate: a rename of "C" to "A" logs 'duplicate name "C"'. It should name the requested name, "A". The two rename cases of test_context_names that pinned the old text now expect "A". obs_source_set_name() with NULL on a public source passes NULL to HASH_FIND_STR and crashes. test_rename_null expects what a NULL name gets on create, and what an empty rename gets: the next unnamed name, for an input and for a source that needs a canvas. Refs obs-rust#1787
…L rename obs_context_data_setname_ht() logged context->name as the duplicate name, but by then that is still the old name (it was only pushed to the rename cache), so a rename of "C" to "A" logged 'duplicate name "C"'. It now logs the requested name. A NULL name went to the dedup lookup, whose HASH_FIND_STR calls strlen() on it and crashed once the table held another context. A NULL rename now skips the lookup and takes the unnamed name from dup_name(), as a NULL name on create and an empty rename do. A private source keeps its NULL name as before (obs_context_data_setname()). Refs obs-rust#1787
rdoupe
force-pushed
the
fix/context-rename-warning
branch
from
October 22, 2026 17:07
53e88bf to
fc6dd0b
Compare
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1787 (PR 2 of the plan: the two rename fixes. The port follows.)
What and why
Two spec-following fixes in
obs_context_data_setname_ht()(libobs/obs.c.h), the rename of a context that has a name table: public sources (obs_source_set_name()), sources that need a canvas, such as scenes (obs_canvas_rename_source()), and public canvases (obs_canvas_set_name()). #1788 pinned both as "characterized, not endorsed". The dedup inobs-context-names.c.his not changed.context->nameas the duplicate. At that pointcontext->nameis still the old name: it has only been pushed to the rename cache. So a rename of"C"to"A"while"A"is taken loggedAttempted to rename context to duplicate name "C"! New name has been changed to "A 2". It now logsduplicate name "A", as the insert warning (obs_context_data_insert_name()) already names the requested name. The resulting name,"A 2", is unchanged.obs_source_set_name(source, NULL)on a public source, or on a source that needs a canvas, passed NULL to the dedup lookup, whoseHASH_FIND_STRcallsstrlen()on it. That crashed as soon as the table held another context (with the table otherwise empty, the optimized build tested here skipped thestrlen(), so the crash depends on what else is loaded). Only a plugin or script can pass NULL; obs-websocket refuses an empty or missing name. Now a NULL name skips the lookup and goes todup_name(), which gives it the next unnamed name ("__unnamed%04lld"), as an empty rename gets.Why the unnamed name and not "ignore".
obs_source_set_name()already treats NULL like an empty name: its guard lets both through as a rename, and only the public path then crashed. The rest of the API does the same:obs_source_create()with NULL gets an unnamed name, as with"".""gets an unnamed name.dup_name()and becomes nameless again, as a private source created with NULL is. The test pins that, and this change leaves it alone.So a NULL rename now gets what a NULL name gets on create, on every path. Ignoring it, as
obs_encoder_set_name()andobs_canvas_set_name()do (they ignore NULL and""alike), would make NULL and""differ for sources, and would change the private path, which works today.obs_canvas_set_name()returns before any rename for NULL, so canvases are not affected. The fix is one condition inobs_context_data_setname_ht().obs_context_name_deduplicate()is unchanged and still passes a NULL name toexists()as it is (test_context_name_helperspins that);obs.cno longer asks it with NULL.Unchanged, and still pinned as "not endorsed":
"A 2"to"A"while"A"is taken leaves it"A 2", with the warning and arenamesignal from"A 2"to"A 2". Only the warning text changes, from"A 2"to"A".unnamed_indexis incremented without a lock.Upstream (obsproject/obs-studio master,
libobs/obs.c) has both bugs: the samecontext->namein the warning, and the same NULL intoHASH_FIND_STR. The line is under "Fixed upstream bugs", Stability, indocs/features.md. I found no upstream issue for either.RED → GREEN
f671fb87btest: Expect the requested name in the rename warning and a NULL rename. On master's libobs,test_context_namesfails 2 of 15 on the C backend, the hybrid libobs and libobs-c-reference:test_rename("... duplicate name "C"! ..." != "... duplicate name "A"! ..."), andtest_rename_null, which crashes with a segmentation fault in the rename to NULL. The crash leaves libobs started, so the two cases after it (test_canvas_sources,test_canvases) skip in the RED run.test_context_name_helperspasses 12/12.fc6dd0b79libobs: Name the requested name in the rename warning, and take a NULL rename.test_context_names15/15 andtest_context_name_helpers12/12 against libobs with the C backend, the hybrid libobs and libobs-c-reference.OBS_LIBOBS_BACKEND=C, andHYBRIDwithOBS_BUILD_C_REFERENCE=ON, both full builds. Fullctest -j4, headless (private Xvfb, private D-Bus, fresh HOME):OBS_LIBOBS_BACKEND=CHYBRID,OBS_BUILD_C_REFERENCE=ONHYBRID,OBS_BUILD_C_REFERENCE=ONOn the hybrid libobs and libobs-c-reference nothing was skipped or failed to run, on the final head (after the rebase onto #1800) and before it. On the C backend,
test_audio_controlsfails in its setup:obs_startup()fails when Xvfb resets between its cases (its ctest entry runsxvfb-runwithout-noreset). It fails the same way with master'sobs.c.h, run alone, so it is not this change.test_pulse_stream_restartfailed once in one C-backend run and passed in the other. Both context tests pass on that build. In one earlier hybrid run,test_pipewire_screencast_shmfailed once and then passed 3 of 3 runs alone.uv run ci/local_gate.py --lane lintpassed. clang-format is clean on the changed files.test_context_nameschecks the full text through the libobs log handler. The NULL rename is reachable only from a plugin or script.Windows/macOS: not built there. The change has no platform conditional, and the new case uses only the public API, like the rest of
test_context_names.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)