You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: libobs: obs_shutdown frees source type ids before canvases release their scenes (heap-use-after-free) #2017
ASan reports a heap-use-after-free in test_context_names at shutdown (Sanitizers asan run 40044944211, artifact sanitize-asan, tests/test_context_names.asan.*):
obs_shutdown() frees every registered source type's id (and calls free_type_data) before obs_free_data() releases the canvases. obs_canvas_destroy() then calls obs_source_is_scene() on each source still in a SCENE_REF canvas, and that strcmps source->info.id, a pointer into the freed registration. Any source destroyed in obs_free_data() reads its type's info after the type is gone.
Upstream OBS has the same order. Low risk: only reached at shutdown with sources still alive (a host that doesn't release its scenes first). Only trusted local input reaches it.
Fix sketch
Free the registered type tables (source_types ids and type_data, and the output, encoder and service type_data) after obs_free_data(), so no object outlives its type's registration. Test: a cmocka test that leaves a scene in the main canvas at obs_shutdown() and checks that the scene's type is still readable while it is destroyed (for example, its destroy callback reads obs_source_get_id). Tier 2 against the C reference and the hybrid libobs.
Plan (one PR): a RED Tier 2 cmocka test, a scene left in the main canvas at obs_shutdown() whose destroy path reads its type id, first against the C reference; then GREEN: free the registered type tables after obs_free_data(). PR today.
Fixed by #2022 (merged). obs_shutdown now frees the registered source types after obs_free_data. The new test, test_shutdown_type_lifetime, covers it. Nothing left to do here.
Activity
zackees commentedon Oct 24, 2026
Claiming: #2017.
Plan (one PR): a RED Tier 2 cmocka test, a scene left in the main canvas at
obs_shutdown()whose destroy path reads its type id, first against the C reference; then GREEN: free the registered type tables afterobs_free_data(). PR today.libobs: free registered types after obs_free_data() in obs_shutdown() (…
zackees commentedon Oct 24, 2026
Fixed by #2022 (merged). obs_shutdown now frees the registered source types after obs_free_data. The new test, test_shutdown_type_lifetime, covers it. Nothing left to do here.