Skip to content

obs-data: Port libobs/obs-data.c - #801

Merged
zackees merged 5 commits into
obs-rust:masterfrom
nathan-v:port/obs-data
Oct 15, 2026
Merged

zackees merged 5 commits into
obs-rust:masterfrom
nathan-v:port/obs-data

Conversation

@nathan-v

Copy link
Copy Markdown
Contributor

Fixes #784
Refs #444

What and why

Ports libobs/obs-data.c into the obs-data crate. ENABLE_RUST_LIBOBS drops the C file. obs-data.h is unchanged, and obs_data_newref stays inline there. JSON text still comes from jansson 2.14, with JSON_REJECT_DUPLICATES on load and JSON_PRESERVE_ORDER plus compact or indent 4 on dump.

Item pointers stay stable across set. C may realloc the item. A user value left in place when set_autoselect changes the type stays unread by the new type's getters, which return the empty value. The safe core replaces a file by removing the destination and renaming, and it does not log. The C shim calls os_quick_write_utf8_file and os_quick_write_utf8_file_safe. A null name, or a null vec out-pointer, does nothing.

RED → GREEN

  • RED commit: 4b1760d05. soldr cargo test -p obs-data panics in Data::new and Data::from_json. 9 failed in tests/obs_data.rs, 4 failed in tests/parity.rs. The layout test passes.
  • GREEN: 0673c0795. soldr cargo test -p obs-data passes (9 Tier 1, 4 parity, 1 layout). soldr cargo clippy -p obs-data --all-targets -- -D warnings is clean. soldr cargo test -p obs-util --test export_list passes. Rounding 1.5 instead of truncating toward zero fails test_scalars_and_json (got 2, wanted 1). Tier 2 test_obs_data is 8/8 with ENABLE_RUST_LIBOBS OFF and ON, local Xcode RelWithDebInfo. The ON link drops obs-data.o. linux-validate was not run.

Checklist

  • Base is master
  • Claimed rust: Port libobs/obs-data.c to obs-data #784
  • Characterization is test: characterize obs-data.c before port #788, then RED, then GREEN
  • Local gate was not stamped, so PR CI runs the suite
  • No project warning-flag change, so no ci-full label. The oracle build suppresses -Wdeprecated-declarations so obs-data.c's own autoselect calls compile, and the wrapper pragma covers -Wsign-conversion and -Wdouble-promotion in that file.
  • Intentional differences are in tests/parity.rs and rust/README.md

@nathan-v
nathan-v requested a review from zackees as a code owner October 15, 2026 05:03
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member

CI on ba3287fcb (run 38686719670) fails in the C oracle build on Linux, which then cascades into the lint/Rust Tests/Tier 2 failures:

libobs/util/threading.h:62:23: error: implicit declaration of function 'pthread_mutexattr_settype'
libobs/util/threading.h:62:56: error: 'PTHREAD_MUTEX_RECURSIVE' undeclared

glibc only declares these with _GNU_SOURCE (or _XOPEN_SOURCE >= 500). The new obs-data oracle wrapper appears to include util/threading.h (via obs-data.c) before any feature macro. Defining _GNU_SOURCE at the very top of that wrapper, before the first include (the way other oracle wrappers do), should fix it. Reproduce with uv run ci/local_gate.py --lane rust-test. I'll land it through the queue once it's green.

@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member

207d26ff6 fixes the Linux link (thanks). Run 38694283337 still has two failures:

  • Rust Tier 2 Linux: 60/234 Test #60: test_async_delay_audio ... ***Failed 51.87 sec. It isn't a known flake, and it drives the Video Delay (Async) filter, whose delay comes from obs_data settings. So it's worth checking with ENABLE_RUST_LIBOBS=ON that the Rust obs-data returns the same int/double for the filter's settings (default vs user value, autoselect) as the C did.
  • Rust Tests (ubuntu): lane rust-test: FAILED (101). Reproduce with uv run ci/local_gate.py --lane rust-test; it covers host tests plus the windows-gnu --no-run build.

I'll land it through the queue once CI is green.

Tier 1 and the in-memory parity tests panic in Data::new
and Data::from_json. soldr cargo test -p obs-data reports
9 failed in tests/obs_data.rs and 4 failed in tests/parity.rs.
The layout test passes.

Refs obs-rust#784
Refs obs-rust#444
The safe core and the C shims replace obs-data.c when
ENABLE_RUST_LIBOBS is on. JSON text still comes from
jansson 2.14 with the same flags. soldr cargo test -p obs-data
passes, including the oracle parity tests.

A get_int of 1.5 fails the scalar test if it rounds instead
of truncating toward zero.

Refs obs-rust#784
Refs obs-rust#444
Rust Tests failed on all three hosts. rustfmt wants data_ffi
between codec_ffi and graphics_ffi. On Windows the lib test
harness links the no_mangle shims, and nothing in that harness
referenced the oracle or obs-util, so jansson, blog, the
os_quick_* helpers, bfree, os_file_exists and os_rename were
undefined. The integration tests already pull those crates in.
glibc hides PTHREAD_MUTEX_RECURSIVE unless _GNU_SOURCE is set
before obs-data.c includes util/threading.h. The oracle wrapper
now defines it, the same way base.c and task.c do.

obs_data_json_decref is the jansson glue. Hide it in the ELF
version script and the macOS unexport list so the Tier 2 symbol
diff stays empty.

On Ubuntu, GNU ld --as-needed drops the first -ljansson because
the json_* references live in the Rust staticlib, which is linked
after that library. Every cmocka executable then fails. Link
jansson again after the archive.
The windows-gnu probe compiles vendored jansson with this header
first. __int64 is an MSVC keyword, and MinGW has not defined it
yet, so the ssize_t typedef fails. MSVC still uses __int64.
MinGW gets ssize_t from its own headers.

Local-Gate: v1 tree=1e0d1ebc42540b4d58d9f10042ececb0ed1018f0 secs=1640 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1792067595,"gate":"rust/all/fmt","host":"linux-x86_64","key":"392c52b2828470fa6e6ed71abbcacb73f0e96cc6c4088a7ded7a3d93825aaf29","lane":"lint","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":55,"stamp":"b5be4c0a9f8d91bbba202a955cfe88dd","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"392c52b2828470fa6e6ed71abbcacb73f0e96cc6c4088a7ded7a3d93825aaf29","lane":"lint","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":55,"stamp":"7faa5ac02ace7b8ed49c55e9447c6198","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"b439b6bb8e93d470e14a03d649bc23f7eaf68584c1ca2d2ea0ae5f94c9c3850e","lane":"rust-test","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":128,"stamp":"0f9c18a82ffed70324eed5b86ac698dd","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"ab678a7180dcb94814b99979da516000b7c5ef3a99bec31bcafe71005b209895","lane":"cross","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":123,"stamp":"9adba49c61fa5e1b6405103bba1d72a1","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"ab678a7180dcb94814b99979da516000b7c5ef3a99bec31bcafe71005b209895","lane":"cross","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":123,"stamp":"f541a0355c8412196b161665f53d47a9","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"ab678a7180dcb94814b99979da516000b7c5ef3a99bec31bcafe71005b209895","lane":"cross","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":123,"stamp":"d6f7ff4cbb94bb20cf3057f41c624af6","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"ab678a7180dcb94814b99979da516000b7c5ef3a99bec31bcafe71005b209895","lane":"cross","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":123,"stamp":"1d2575b4ef19d46c958fcea2694e54f9","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"ab678a7180dcb94814b99979da516000b7c5ef3a99bec31bcafe71005b209895","lane":"cross","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":123,"stamp":"3dfbc45c13134b68c75c5ca15c6c409b","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"ab678a7180dcb94814b99979da516000b7c5ef3a99bec31bcafe71005b209895","lane":"cross","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":123,"stamp":"88ca004c95f7cabf5f7f9643b7554536","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
Ci-Attestation: {"at":1792067595,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"a5cb0863f2983715d83c7defd3929baad8142dee91d2a6b64512b28652907a24","lane":"tier2-linux","parents":["9787ef86f09b0a28c702f9eae176b837dcc23d95"],"secs":1333,"stamp":"3747f6990b23cda2d2ebed5e30331c42","tree":"1e0d1ebc42540b4d58d9f10042ececb0ed1018f0","v":1,"via":"run"}
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member

Rebased onto master and ran the stamped local gate on your latest head (CI was green). Your characterization (#788) → RED (4b1760d05) → GREEN evidence stands; queued for the merge queue.

  • Rebased on master, local gate passed; pushed as fe82240.

@zackees
zackees added this pull request to the merge queue Oct 15, 2026
Merged via the queue into obs-rust:master with commit 76c4892 Oct 15, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

rust: Port libobs/obs-data.c to obs-data

2 participants