Skip to content

rust: Port callback/signal.c to obs-callback #1441

Closed

Description

@vpacher

Unit

libobs/callback/signal.c.h (signal.h): signal_handler_create, _destroy, _add, _connect, _connect_ref, _disconnect, _connect_global, _disconnect_global, _remove_current, _signal. The event system of the libobs core. Target crate: obs-callback. Part of #1437.

Phase and position

Last slice: it needs decl and calldata and has the most state. Users: 12 libobs files, 15 plugin files, 16 frontend files. If the characterization shows parts that can be separated (for example the global callbacks), this can split into two PRs.

Dependencies and existing tests

decl, calldata, threading (recursive mutexes, atomics; ported), darray/bmem (ported). No cmocka test for the handler itself. Steps: characterization test test/cmocka/test_signal.c, RED, GREEN, Tier 3 against the C oracle, plus a concurrency test (connect and disconnect from other threads while signalling) under TSan.

Notes

To characterize:

  • Disconnect while the signal runs only marks the callback (remove), and the signal loop erases it after the callbacks run. Connect while it runs appends.
  • signal_handler_remove_current uses thread-local pointers to the running callback (current_signal_cb, current_global_cb).
  • keep_ref (signal_handler_connect_ref) adds a reference to the handler, and the handler is freed when the last reference goes (signal_handler_destroy drops one).
  • The per-signal and global-callback mutexes are recursive, the handler mutex is not.
  • Logged cases: an invalid declaration, a signal that exists, a connect to a signal that is not there.

To check during characterization (not confirmed): if a callback connects to the same signal while it runs and da_push_back reallocates the array, the thread-local current_signal_cb may point into the old array for a later signal_handler_remove_current in that callback.

🤖 Generated with Claude Code

Activity

  1. vpacher commented on Oct 19, 2026

    @vpacher
    MemberAuthor

    Claiming: #1441

    First steps: the characterization test test/cmocka/test_signal.c against the C (registered in tests.d/), then the port into rust/obs-callback with RED and GREEN and a Tier 3 test against the C oracle. The test pins connect and disconnect, global handlers, a disconnect during a signal (deferred remove), keep_ref refcounting, and a connect during a signal (the handler array can reallocate while current_signal_cb points into it).

  2. added
    claimed
    on Oct 19, 2026
  3. vpacher commented on Oct 21, 2026

    @vpacher
    MemberAuthor

    Status: the Rust port of signal.c is done locally and rebased onto #1556 (Tier 1 and Tier 3 green, the C test cases mirrored). @zackees, could you check your inbox for it? I am still on this issue. I hold the PR until I have an answer to the email I sent on 2026-10-20.

  4. zackees commented on Oct 21, 2026

    @zackees
    Member

    @vpacher The report you mean is the private advisory you filed on 2026-10-19 for libobs/callback/signal.c. Here are the answers to your questions:

    Sorry for the slow reply on the advisory. Thanks for reporting it privately.

  5. zackees commented on Oct 21, 2026

    @zackees
    Member

    @vpacher The maintainer has decided on the private advisory you filed on 2026-10-20 (see its description), and its private fork is ready for your fix.

  6. vpacher commented on Oct 21, 2026

    @vpacher
    MemberAuthor

    @zackees Thanks. I think you missed a comment I left in the advisory earlier today (about 2:20 a.m. PDT). Can you re-check it, please, before I push?

  7. zackees commented on Oct 21, 2026

    @zackees
    Member

    @vpacher You're right, and I'm sorry: I missed your 09:17Z comment on GHSA-rjwf. #1556 fixed only the signal-callback part, and the advisory was published while the global-callback part is still on master. Comments on it are now closed, so I'm answering here.

    Because the advisory is already public, keeping the fix private no longer helps. Please open the C fix (track the global callback by index, as you described), its RED test and your signal.c port as normal public PRs now, and link them here. They'll go through the merge queue as soon as they're green. I've marked the advisory as partly fixed until then. Nobody else is pushing a fix; it's yours.

  8. vpacher commented on Oct 21, 2026

    @vpacher
    MemberAuthor

    PR A: #1639 (C fix for the global callbacks, RED then GREEN). The signal.c port follows on top of it.

  9. zackees commented on Oct 21, 2026

    @zackees
    Member

    @vpacher Thanks. #1639 is green and in the merge queue. After it lands, please confirm on #1639 that both reproductions from your report now pass. I'll then take the "partly fixed" note off GHSA-rjwf.

  10. vpacher commented on Oct 21, 2026

    @vpacher
    MemberAuthor

    PR B: #1642 (signal.c port, Fixes #1441). #1639 is merged; I'll confirm the reproductions on #1639 next.

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