Skip to content

build: state the other get_bit1 shift and link libm where the sanitizer needs it (#2923) - #2935

Merged
zackees merged 2 commits into
masterfrom
fix/2923-sanitizer-followup
Oct 29, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/2923-sanitizer-followup

Conversation

@zackees

@zackees zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member

Refs #2923. The two commits #2925 was missing when it merged.

#2925 (6c5fd4516 on master) stated the conversions and the gl_enable_debug prototype the Sanitizers lane reported. Two more findings came out of the Sanitizers dispatches on that branch, and they are here:

1. get_bit1()'s left shift

asan 🧪 on 40893068597 (artifact sanitize-asan) still reported rtmp-av1.c.h:109. Line 109 is the left compound shift result <<= index & 7; #2925 had only stated the right shift one line below (>>= 8 - 1), because the issue's table paired both diagnostics with that line.

plugins/obs-outputs/rtmp-av1.c.h:109:20: error: conversion from 'int' to 'uint8_t' may change value [-Werror=conversion]

562079974/3be224fd1 states it the same way. The compound assignment already truncated modulo 256, so no value changes.

2. test_scene_crop_steps needs libm when sanitized

valgrind 🧪 on the same branch builds all 2204 targets and then fails at link, which it never reached before because the compile errors stopped the build:

ld: test_scene_crop_steps.c.o: undefined reference to symbol 'ceilf@@GLIBC_2.2.5'
/usr/lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line

The lane's global -fsanitize=undefined,float-cast-overflow makes UBSan emit ceilf/floorf calls for the float→int casts, and libobs links m privately so it does not propagate. The other scene-step tests already link m under if(NOT MSVC); test_scene_crop_steps now does the same.

GREEN

Replay through the compile database on this base, -D_DEBUG, the three groups + -Werror appended:

== OK plugins/linux-v4l2/build/linux-v4l2.nix+.h.c
== OK libobs-opengl/build/opengl.core+.h.c
== OK plugins/obs-outputs/build/obs-outputs.av1+.h.c

./lint clean (== lane lint: ok). ninja -C build test_scene_crop_steps does not exist in this checkout's configuration (cmocka tests are off there), so the CMake change is verified by configuration + the lane, not by a local build of that target.

Still open for a green lane

plugins/obs-outputs/mp4-mux.c.h:524 (asan) and plugins/obs-outputs/rtmp-hevc.c.h:853 (macOS) are on #2922, which is still open. With both PRs in, the Sanitizers and macOS lanes have nothing left from the #2625 ratchet window.

Tiers

No Rust, C-test or protocol change; every edit states a conversion the compiler already performed, or links the library the sanitizer runtime calls. Nothing user-visible.

The asan lane's first run on this branch (40893068597) reports
`rtmp-av1.c.h:109` still: the *left* compound shift, `result <<= index & 7`,
is the one at column 20 — the `-Wconversion` diagnostic the issue table
attributed to line 109 covers both shifts of the byte. State it the same
way as the right shift below it: `result = (uint8_t)(result << (index & 7))`.

The compound assignment already truncated modulo 256, so the cast changes
no value.
With the compile diagnostics gone the valgrind lane reaches linking, where it
had never got to before, and fails on this test:

    ld: .../test_scene_crop_steps.c.o: undefined reference to symbol
    'ceilf@@GLIBC_2.2.5'
    /usr/lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing
    from command line

The sanitizer flags include `float-cast-overflow`, whose checks call
ceilf/floorf, and `libobs` links `m` privately, so it does not propagate. The
other scene-step tests already link `m` under `if(NOT MSVC)`; this one now
does too.

Masked until now: the lane stopped at the compile errors above, long before
this link.

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: correct and mechanical, no value change

Checked both hunks against master 9ad455e9a.

plugins/obs-outputs/rtmp-av1.c.h:109 — result = (uint8_t)(result << (index & 7)) is exactly what the compound assignment already did: result <<= n promotes result to int, shifts, then converts back to uint8_t (mod 256). The explicit cast states that conversion; it does not add one. The matching >>= 8 - 1 on the next line was already stated by #2925, so the pair is now consistent.

test_scene_crop_steps.cmake — adding m under if(NOT MSVC) matches the 23 other tests.d/*.cmake fragments that link m this way, and the quoted link error (ceilf@@GLIBC_2.2.5, DSO missing from command line) is what a sanitized float→int cast produces when libobs links m privately. No test semantics change.

Two small notes, neither blocking:

  1. #2929 already carries the rtmp-hevc conversions and #2922 the mp4-mux one, so the "Still open for a green lane" paragraph will read oddly once those land — worth a one-line update when #2922 merges.
  2. 562079974/3be224fd1 in the body reads like a truncated commit pair; double-check it is the intended reference.

Verdict: correct and mechanical — no value change at either site. OK to queue once checks finish.

@zackees
zackees added this pull request to the merge queue Oct 29, 2026
@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator

Local gate run on this branch; HEAD stamped and pushed unchanged; auto-merge on (the PR reports it is already queued). Remaining work on #2923 (the valgrind v4l2 format mismatch) stays open on the issue.

Merged via the queue into master with commit 6d5ba5f Oct 29, 2026
41 of 43 checks passed
@zackees
zackees deleted the fix/2923-sanitizer-followup branch October 29, 2026 17:02
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.

1 participant