Skip to content

rust: Port the registration copy size rules in obs-module.c to obs-core #2860

Closed

Description

@rdoupe

Unit

libobs/obs-module.c.h: the size rules of type registration (how much of the caller's obs_source_info, obs_output_info, obs_encoder_info or obs_service_info is copied, whether a field lies wholly within the caller's size, the zero-size and too-large gates of REGISTER_OBS_DEF, and the transition rule that ignores get_width/get_height), moved to libobs/obs-module-register-copy.c.h and ported to rust/obs-core as a new module module_register_copy, next to module_source_rules, module_type_rules and module_load_rules.

Phase and position

Phase 6 (libobs core), one more unit of the remaining obs-module.c.h C; tracking issue #4. It follows the fix for registrations that read version and caps past a short structure (#2841, #2844), which has landed.

Dependencies and existing tests

Uses obs_module_source_rules_size_supported (already Rust) for the too-large gate. The callback checks are already Rust (module_source_rules, module_type_rules), and test_register_short_info (#2844) registers short source and encoder infos. No test pins the copy length for every size, the in-size rule of each callback, the free on error, or the zero-size gate, so a characterization test (test_module_register_copy_steps) lands first, with fake info structures of each size, for all four types.

Scope

Rust takes over these decisions:

  • whole_fields_size: the copy ends at the size rounded down to a pointer, or at the end of a 32-bit field that starts there and lies wholly within the size (the pointer size and the 32-bit field offsets are passed in by C, so the core is right on 32-bit builds);
  • HAS_VAL and HANDLE_ERROR: a field counts only when it lies wholly within the size;
  • REGISTER_OBS_DEF: a size of 0 is outside obs_module_load, a size past sizeof is too large, otherwise copy;
  • obs_register_source_s: a transition's get_width and get_height are warned about and ignored.

C keeps every offsetof/sizeof, every pointer read (each still under its in-size check), every memcpy, da_push_back, bstrdup, lookup, blog and the free_type_data call, each where it is today.

Plan

The standard six commits: move, characterization, Tier 1 RED, GREEN in a libobs.ported-module-register-copy group, Tier 3 parity, docs.

Notes

No SIMD, no per-OS code, no threads. Expected intentional differences: none on reachable inputs (offsets are offsetof constants; a field end past SIZE_MAX is unreachable).

Activity

  1. added
    enhancement
    port
    on Oct 29, 2026
  2. rdoupe commented on Oct 29, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2860.

    1. Move the copy size, in-size, zero-size/too-large gate and transition rules of obs-module.c.h into libobs/obs-module-register-copy.c.h, declared in libobs/obs-module-register-copy.h without EXPORT, with every offsetof, pointer read, copy, push and log left where it is (a scratch harness compares master's macros and copy-size functions with the moved ones over a logging stand-in).
    2. Characterization: test_module_register_copy_steps, registering fake infos of every edge size for all four types against the real libobs.
    3. RED: obs_core::module_register_copy Tier 1 against todo!() stubs.
    4. GREEN: the safe core and the shims, the file in libobs.ported-module-register-copy.
    5. Tier 3 parity against the C (every size up to sizeof + 8 for each type at both pointer widths, plus proptests) with a mutation check.
    6. Docs: rust/README.md, naming.md, the crate description and module docs.

    The draft PR should be up within a few hours, once the RED commit exists.

  3. added
    ready
    on Oct 29, 2026
  4. rdoupe commented on Oct 29, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by PR #2861 (merged, fe82f88): the size rules of type registration (how much of a plugin's source, output, encoder or service info is copied, whether a field lies wholly within the plugin's size, the zero-size and too-large checks, and the transition rule that ignores get_width/get_height) now live in obs_core::module_register_copy, with the C moved to libobs/obs-module-register-copy.c.h (group libobs.ported-module-register-copy). Tier 1, Tier 3 parity with a mutation check, and the ASan/UBSan characterization test test_module_register_copy_steps are in.

    What is left: C keeps every offsetof()/sizeof(), pointer read, memcpy(), da_push_back(), lookup, blog() and the free_type_data call, as planned. The rest of libobs/obs-module.c.h (module metadata loading, locale lookup, open/create/init bookkeeping, module enumeration) is still C.

    Follow-up issue: none filed yet for that rest; the next unit of it gets its own port issue.

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

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions