Skip to content

libobs: Read the remaining graphics inputs before writing dst - #680

Merged
zackees merged 3 commits into
obs-rust:masterfrom
nathan-v:fix/370-graphics-alias
Oct 14, 2026
Merged

zackees merged 3 commits into
obs-rust:masterfrom
nathan-v:fix/370-graphics-alias

Conversation

@nathan-v

@nathan-v nathan-v commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

The other twelve functions from #370, plus the private helper get_3x3_submatrix, stored a lane and then read an input that shared that storage. Each one now copies what it still needs, then writes. Signatures stay as they are. get_3x3_submatrix stays static.

quat_mul and calc_torque in the Rust shims were re-reading after that store so they would match the old C result. They read first now.

One overlapping result changes. calc_torque with dst == v1, v1 (10, 0, 0), v2 at the origin, torque 0.5, used to come back (-10, 0, 0). That was the scaled direction added to itself. The separate-storage result is (5, 0, 0), and the aliased call matches it. test_calc_torque_dst_aliases_v1 expects (5, 0, 0). Calls that do not overlap are unchanged.

get_3x3_submatrix has no cmocka entry. Exporting it would be a new symbol. Callers already pass a local 9-float buffer. The Rust matrix4 submatrix already copied its input.

Motivation and Context

Fixes #370. The bounds and plane half landed in #423.

How Has This Been Tested?

RED is c5c2a2f92. graphics_alias_rest was 10 failed, 0 passed. The shim or the C oracle disagreed with the separate-storage result for quat_mul, quat_from_matrix4, quat_from_matrix3, vec3_rotate, vec3_transform3x4, matrix3_scale, matrix3_mirrorv, matrix3_mirror, calc_torque, and polar_to_norm.

GREEN is 70b2528dc. Those 10 pass. dfac4b3ba includes plane.h so the cmocka mirror case compiles. matrix3.h only names struct plane.

Host is macOS aarch64, soldr 0.9.31:

  • soldr cargo fmt --all --check
  • soldr cargo clippy --workspace --all-targets --locked -- -D warnings
  • soldr cargo dylint --all -- --workspace --lib --bins
  • soldr cargo test --workspace --locked

./lint stops in its Python self-test on this machine. ci/test_local_gate_probe.py runs soldr cargo test --target x86_64-pc-windows-gnu, and soldr 0.9.31 refuses that target on macOS. ci/test_windows_package_arguments.py fails when pwsh is installed: PowerShell returns /private/var/... and the test expects /var/.... There is no local-gate stamp. This is a fork PR, so the Linux jobs run on GitHub anyway.

Linux Docker is image obs-rust-linux-validate, arm64 Ubuntu 26.04, gcc 15.2.0, rustc 1.98.1. The container is arm64. The GitHub ubuntu-26.04 job is x86_64.

rust/tools/linux-validate/run.sh:

== ported objects checked with ENABLE_RUST_LIBOBS=ON: 41
== [OFF] ctest
100% tests passed, 0 tests failed out of 194
== [OFF] obs-nvenc.so built with cuda-load.c.o
== [ON] ctest
100% tests passed, 0 tests failed out of 194
== [ON] obs-nvenc.so built with cuda-load-rust.c.o
== [ON/Debug] Rust staticlib profile
/cargo/build/aarch64-unknown-linux-gnu/release/liblibobs_rust.a
== libobs exported symbols, OFF vs ON
IDENTICAL (1766 symbols)
== lane tier2-linux: ok (140.4s)

test_graphics_alias_rest and test_math_extra passed OFF and ON.

cargo test -p obs-graphics in that image did not run. The oracle builds wcsdepad with -Werror=sign-conversion, and arm64 wchar_t is unsigned, so the compile stops in dstr-libc.c. The x86_64 runner does not hit that. Tier 2 uses -Wno-sign-conversion and did build.

Codex and a second static review both came back clean. Neither ran the suite.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Overlapping calc_torque is the one call whose result changes. It now matches the separate-storage call.

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

The twelve functions left on obs-rust#370 still return a different
value when dst overlaps an input. These tests run each
public one on separate storage and on that overlap.

graphics_alias_rest: 10 failed, 0 passed. The cmocka
twin is test_graphics_alias_rest. get_3x3_submatrix is
static, so it has no test entry. gs_u8x4_to_float4 is
only in the cmocka file.
Snapshot the lanes each function reads again after storing dst.
quat_mul and calc_torque shims were copying that second read; they
now use the values taken before the store. Non-overlapping calls
are unchanged. test_calc_torque_dst_aliases_v1 now expects (5, 0, 0).
The mirror case builds a plane. matrix3.h only names it, so the
Linux cmocka build rejected the union.

Local-Gate: v1 tree=8b012803f640e9a444ca6e0faeac71a7c6094836 secs=495 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791956953,"gate":"rust/all/fmt","host":"linux-x86_64","key":"0a90b8b12a4804ae2e72554f958fee6c329a62b1e580ac0a6244221245bfab72","lane":"lint","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":43,"stamp":"f9d1e5e8f9f70b38f863e6b41ae20740","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"0a90b8b12a4804ae2e72554f958fee6c329a62b1e580ac0a6244221245bfab72","lane":"lint","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":43,"stamp":"d3dd19c70127c214d8da0c53bba8f4f4","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"cb8666bbbc9479aad98e77d1fce4bd3565a11f0b124cf084a7a8cd3a3ffceabf","lane":"rust-test","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":122,"stamp":"8a4ebf3c0d85fb183e96cd654fd148a6","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"5301910eb3f2675848ce30ef0fe7308ee7ee7a72ad0d75c337850cc699f97d02","lane":"cross","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":114,"stamp":"43677f364173669518f0b33cf9a65d23","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"5301910eb3f2675848ce30ef0fe7308ee7ee7a72ad0d75c337850cc699f97d02","lane":"cross","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":114,"stamp":"dc1f9e8bee8ef7b17f25c79cc90819d4","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"5301910eb3f2675848ce30ef0fe7308ee7ee7a72ad0d75c337850cc699f97d02","lane":"cross","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":114,"stamp":"cb76a7d1a1bea4582c2d74a91ac28e6c","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"5301910eb3f2675848ce30ef0fe7308ee7ee7a72ad0d75c337850cc699f97d02","lane":"cross","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":114,"stamp":"4d5c7fc30574031efefb98cd1f26f636","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"5301910eb3f2675848ce30ef0fe7308ee7ee7a72ad0d75c337850cc699f97d02","lane":"cross","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":114,"stamp":"5a22640db95b0865b4f4bfb9d136d087","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"5301910eb3f2675848ce30ef0fe7308ee7ee7a72ad0d75c337850cc699f97d02","lane":"cross","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":114,"stamp":"838fece41d7263832529d65c89f2bebd","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
Ci-Attestation: {"at":1791956953,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"14e3dc82055d93fb556941051e7364a305b06398a89693210c2ef22b75e49f7b","lane":"tier2-linux","parents":["8f556380021e029d1b520f4a7e8f92f601a6fe16"],"secs":216,"stamp":"ba37afd5a3e78c2ad6f4c7ca14eac522","tree":"8b012803f640e9a444ca6e0faeac71a7c6094836","v":1,"via":"run"}
@zackees

zackees commented Oct 14, 2026

Copy link
Copy Markdown
Member

Verified red → green locally (soldr cargo test -p obs-graphics --test graphics_alias_rest, which runs the shim against the C oracle):

  • c5c2a2f92 (RED): fails, including calc_torque_overlap_matches_separate, matrix3_mirror_dir_aliases_x, matrix3_mirrorv_v_aliases_x, polar_to_norm_same_address.
  • dfac4b3ba (GREEN): 10 passed; 0 failed.

On the edit to the existing test_math_extra.c: that case documented the old aliased result as "Characterized, not endorsed", and this PR fixes that behaviour in both C and Rust. The new expectation (5, 0, 0) is the separate-storage result, so the edit is allowed. It is not a test changed to make a port pass.

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

@zackees
zackees force-pushed the fix/370-graphics-alias branch from dfac4b3 to a9d88cf Compare October 14, 2026 05:49
@zackees
zackees merged commit bc87034 into obs-rust:master Oct 14, 2026
21 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.

bug: graphics math: 17 functions give a wrong result when dst overlaps an input

2 participants