Repository navigation
libobs/graphics: Check the graphics context in gs_matrix_scale3f (#2518) - #2520
Merged
Merged
Conversation
… (RED, #2518) test_graphics_no_context calls the fourteen gs_matrix_* functions and gs_viewport_push/pop, gs_blend_state_push/pop and gs_reset_blend_state without a graphics context on the thread, with a log handler. Each one is expected to return and log "<name>: called while not in a graphics context" (gs_valid, LOG_DEBUG), as thirteen of the matrix functions and the stack functions do. RED: gs_matrix_scale3f reads thread_graphics without gs_valid and dereferences NULL (the test crashes); gs_reset_blend_state logs the name gs_preprocessor_name. Refs #2518 Co-Authored-By: Claude Opus 5.5 <[email protected]>
gs_matrix_scale3f read thread_graphics without gs_valid, so a call
without a graphics context on the thread (a plugin or a script) crashed
OBS on a NULL dereference. It now checks with gs_valid first, as the
other thirteen gs_matrix_* functions do: it logs "gs_matrix_scale3f:
called while not in a graphics context" (LOG_DEBUG) and returns.
gs_reset_blend_state checked with gs_valid("gs_preprocessor_name"), so
its log line named the wrong function (since d242004, 2015); it now
names itself.
Both are unchanged in upstream OBS master.
GREEN: test_graphics_no_context passes on the C reference and the
hybrid libobs.
Fixes #2518
Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
reviewed
Oct 26, 2026
zackees
left a comment
Member
There was a problem hiding this comment.
Reviewed: both fixes are correct and minimal. RED crashes/mislogs on both libobs builds, GREEN fixes it, and the new test covers all fourteen gs_matrix_* functions plus the viewport and blend stacks. I pushed the missing features-ledger line under Scripting. Queuing once CI is green.
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.
Fixes #2518
Two small fixes in
libobs/graphics/graphics.c.h, before the port of the graphics state stacks (#2517):gs_matrix_scale3freadthread_graphicswithoutgs_valid, so a call without a graphics context on the thread (a plugin or a script;obsluaandobspythoninclude all ofgraphics.h) crashed OBS on a NULL dereference. It now checks withgs_validfirst, as the other thirteengs_matrix_*functions do: it logsgs_matrix_scale3f: called while not in a graphics context(LOG_DEBUG) and returns.gs_reset_blend_statechecked withgs_valid("gs_preprocessor_name"), so its log line named the wrong function (since d242004, 2015). It now names itself.Both are unchanged in upstream OBS master.
RED → GREEN
526d49662:test_graphics_no_context(new) calls the fourteengs_matrix_*functions,gs_viewport_push/pop,gs_blend_state_push/popandgs_reset_blend_statewithout a graphics context, with a log handler, and expects each one to return and log its own name. Fails on both libobs builds:gs_matrix_scale3fcrashes (segmentation fault),gs_reset_blend_statelogsgs_preprocessor_name.55e555248: the two changes.Tier 2 (Linux x86_64, Debian 13)
ci/local_gate.py --lane lint) passes.test_graphics_no_context,test_texture_render,test_sprite_flip_renderandtest_scene_rotated_scale_filterpass on the hybrid libobs and onlibobs-c-reference(4/4 each).Checklist
mastergs_matrix_scale3foutside a graphics context no longer crashes OBS🤖 Generated with Claude Code