Skip to content

ASan/UBSan: NULL outputHandler deref in OBSBasic::closeWindow when quitting after failed video init #127

Closed

Description

@zackees

Found by the ASan launch pass (meta issue linked as parent). Upstream OBS code, unchanged in this fork.

Crash

==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (T0)
    #0  OBSBasic::closeWindow()  frontend/widgets/OBSBasic.cpp:1848
    #8  QCoreApplication::aboutToQuit()
    #9  QCoreApplication::exit(int)
    #10 xcbSourceDispatch              (X connection broke)
    #16 QDialog::exec()
    #18 OBSErrorBoxva                  shared/qt/wrappers/qt-wrappers.cpp:38
    #20 run_program                    frontend/obs-main.cpp:695

UBSan reports it first: OBSBasic.cpp:1848:37: runtime error: member access within null pointer of type 'struct BasicOutputHandler'.

Cause

closeWindow() calls outputHandler->VirtualCamActive() unconditionally. outputHandler is only created after video init succeeds. If startup fails (here: Failed to initialize video: Graphics module not found), run_program shows an error box. Any quit while that box is open (aboutToQuit → closeWindow) then dereferences NULL.

Repro

Launch OBS so that obs_reset_video fails, e.g. make libobs-opengl.so.30 unloadable. While the "Failed to initialize video" box is up, quit the app (here the X connection dropped). ASan/UBSan build, Xvfb.

Fix

Guard outputHandler (if (outputHandler && outputHandler->VirtualCamActive())) and audit the rest of closeWindow() for other members that only exist after a successful init.

Activity

  1. added
    bug
    on Oct 10, 2026
  2. zackees commented on Oct 13, 2026

    @zackees
    MemberAuthor

    Claiming: frontend shutdown after failed video initialization.

    1. Add a focused RED regression test for the shutdown decision when the output handler is absent.
    2. Guard the virtual-camera shutdown call and audit the remaining close path for startup-only objects.
    3. Run the local gate, then open one PR against master. I expect the first PR today.
  3. added
    claimed
    on Oct 13, 2026
  4. zackees commented on Oct 13, 2026

    @zackees
    MemberAuthor

    Fixed by PR #432, merged into master as 3504531. The shutdown path now handles an absent output handler; the UBSan regression test and local lint/unit gate passed. No remaining work is known for this crash.

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

    bugclaimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions