Skip to content

obs_shutdown leaks the weak canvas refs of sources left alive #2038

Closed

Description

@zackees

ASan (master run 40053887433) reports leaks in test_context_names and test_shutdown_type_lifetime at obs-canvas.c.h:330 (obs_canvas_get_weak_canvas in obs_canvas_insert_source) and at obs-canvas.c.h:158 (the canvas's control block).

obs_free_data() releases the main canvas first and destroys the remaining sources afterwards. obs_canvas_remove_source() releases source->canvas only when obs_weak_canvas_get_canvas() still returns the canvas, and by then it doesn't. So every leftover source leaks its weak ref, and the canvas control block stays referenced.

Fix: release the weak ref whether or not the canvas is still alive. Test: a new cmocka test checks that bnum_allocs() returns to its startup value after shutting down with a source left alive.

Activity

  1. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Claiming: RED cmocka test (bnum_allocs after shutdown), GREEN obs_canvas_remove_source fix. PR today.

  2. added
    claimed
    on Oct 24, 2026
  3. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Fixed by #2041 (merged). After shutdown with sources left alive, the canvas control block and the canvas's source-name table are now freed. What stays by design is one control block per leftover source. Local ./unittest with the fix: 412/412 pass, including test_shutdown_canvas_weak_ref.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions