Skip to content

build: state the conversions and the prototype the Sanitizers lane reports (#2923) - #2925

Merged
zackees merged 3 commits into
masterfrom
fix/2923-sanitizer-conversions
Oct 29, 2026
Merged

zackees merged 3 commits into
masterfrom
fix/2923-sanitizer-conversions

Conversation

@zackees

@zackees zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member

Refs #2923.

Makes the Sanitizers lane green again for everything except the one site #2922 already carries. Nine diagnostics in three commits, no flag, pin or target change:

File Line Diagnostic Fix
plugins/linux-v4l2/v4l2-helpers.c.h 76, 83, 87 %lu from PRIuFAST32 vs uint [-Wformat] cast the arguments to uint_fast32_t
libobs-opengl/gl-subsystem.c.h 115 function declaration isn't a prototype [-Wstrict-prototypes] (void) parameter list, matching the release definition at line 128
plugins/obs-outputs/rtmp-av1.c.h 109, 499, 500 int to uint8_t may change value [-Wconversion] cast at the assignment
plugins/obs-outputs/rtmp-hevc.c.h 827, 843 int to uint8_t may change value [-Wconversion] cast at the s_w8() argument
plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c.h 434, 435 conversion to unsigned int from int may change sign [-Wsign-conversion] 1u << log2_chroma instead of 1 <<

plugins/obs-outputs/mp4-mux.c.h:524 is the ninth site and is not in this PR: #2922 states that conversion, on fix/2921-mp4-mux-conversions. The two PRs touch disjoint lines, and the lane is green only with both.

RED

Lane: run 40884102538 at 32c4bcc19, jobs valgrind 🧪 and asan 🧪. The full diagnostic list is in #2923.

Local replay of the two valgrind 🧪 classes, through this checkout's compile database with -D_DEBUG (the -DDEBUG build above is Release, where v4l2_query_all_buffers() is not compiled at all — that is why the diagnostic only appears in the sanitizer lane):

$ python replay_tu.py build plugins/linux-v4l2/build/linux-v4l2.nix+.h.c --extra -D_DEBUG
== FAIL .../plugins/linux-v4l2/v4l2-helpers.c.h:20:43: error: format '%lu' expects argument of type
   'long unsigned int', but argument 3 has type 'uint' {aka 'unsigned int'} [-Werror=format=]   (x3)
$ python replay_tu.py build libobs-opengl/build/opengl.core+.h.c --extra -D_DEBUG
== FAIL .../libobs-opengl/gl-subsystem.c.h:115:13: error: function declaration isn't a prototype
   [-Werror=strict-prototypes]

The six asan 🧪 conversion diagnostics do not reproduce on this box: the same TUs, the same three warning groups appended, with gcc 13.2, 14.3 and 15.2, stay silent — their range analysis proves those expressions fit, and the asan lane's gcc does not. So for that half the lane log above is the evidence, as #2909 did for the Cocoa seams; the fix is a cast at each site and changes no value.

GREEN

Same replay after the change (-D_DEBUG, 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
== OK plugins/obs-outputs/build/obs-outputs.hevc+.h.c

./lint is clean (== lane lint: ok (49.7s)). The asan 🧪 half is validated by the Sanitizers run dispatched on this branch; its result is in the comments below.

Tiers

No Rust, C-test or protocol change, and no behaviour change to check in the app: every edit either states a conversion the compiler already performed or spells the parameter list. The C tests are untouched. docs/features.md is untouched because nothing user-visible changes.

The mitigation in #2923

The issue's acceptance asks for a mechanism so the next ratchet slice cannot land with a sanitizer-only error. That is a second PR and a design choice (compile each ratcheted target in the -DDEBUG asan tree inside the lane's select passes, versus a checklist line); this PR only makes the lane green.

…2923)

`v4l2_query_all_buffers()` prints the buffer count and the loop index with
`%" PRIuFAST32`, but both are `uint` (unsigned int), while `uint_fast32_t`
is `unsigned long` on 64-bit Linux. The valgrind lane's `-D_DEBUG` build
compiles the function and `-Wformat` rejects the mismatch:

    v4l2-helpers.c.h:20:43: error: format '%lu' expects argument of type
    'long unsigned int', but argument 3 has type 'uint' [-Werror=format=]

The three call sites now cast to `uint_fast32_t`, which is the widening the
format already assumed. Values unchanged.
The debug-output build defines `static void gl_enable_debug()` and the
release build already defines `static void gl_enable_debug(void)`. The
`-Wstrict-prototypes` flag the ratchet turned on rejects the former:

    gl-subsystem.c.h:115:13: error: function declaration isn't a prototype
    [-Werror=strict-prototypes]

The two definitions now agree.
Four bit-pack expressions and two chroma divisions the asan lane compiles
with the conversion groups on. Every cast states the conversion that already
happened; no value changes:

- rtmp-av1 `get_bit1()` shifts a byte right by 7 and stores it back;
- the AV1 sequence header byte and the two HEVC configuration bytes are
  assembled from fields that each already fit their bit positions;
- the VAAPI plane divisors are `1u << log2_chroma`, matching the `unsigned`
  width and height they divide.

Refs #2923.
@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Note on overlap: this PR and #2922 (issue #2921, macOS lane) both state conversions in
plugins/obs-outputs/rtmp-hevc.c.h — lines 827 and 843, in the identical (uint8_t)(...) form —
because the gcc Sanitizers lane and macOS clang both report them.

The one file this PR does not touch but the Sanitizers lane reports is
plugins/obs-outputs/mp4-mux.c.h:524 (s_w8(s, full_range << 7)); that hunk is in #2922, which
also carries the clang-only sites gcc cannot see (mp4-mux.c.h:1119, :1612,
rtmp-hevc.c.h:853, via -Wimplicit-int-conversion-on-negation). So master's Sanitizers lane goes
fully green only when both PRs have landed: keep Refs #2923 here rather than Fixes if this one
queues first.

When the second of the two lands, the other one rebases with nothing left to do beyond dropping the
duplicated hunk; the two hunks are byte-identical, so no conflict in the changed lines.

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

@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.

Reviewed at c246a2810 (five files, +16/−14). Every hunk states a conversion the compiler already performed; no value, flag, pin or behaviour changes, and nothing here is a merge blocker. Notes, none of them requesting a change:

Verified

  • plugins/linux-v4l2/v4l2-helpers.c.h:76,83,87 — struct v4l2_buffer_data.count is uint (v4l2-helpers.h:49), so (uint_fast32_t) is the type PRIuFAST32 names (unsigned long on LP64, unsigned on 32-bit). The three sites were narrowed by #2849, so this restores the format contract rather than papering over it. Only the log line changes; v4l2_query_all_buffers() is #ifdef _DEBUG, which is why the release build never showed it.
  • libobs-opengl/gl-subsystem.c.h:115 — (void) matches the release definition at line 128 (static void gl_enable_debug(void) {}), so the two definitions now agree instead of one carrying upstream's empty parameter list.
  • plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c.h:434,435 — 1u << log2_chroma_w makes the shift unsigned int, so /= no longer converts a signed operand; identical value, and log2_chroma_* is ≤ 1 for the formats reached here, so no shift-width question.
  • plugins/obs-outputs/rtmp-av1.c.h:109,499,500 and rtmp-hevc.c.h:827,843 — the casts are at the assignment/argument, so the byte written is the byte the old code wrote; result = (uint8_t)(result >> 7) is what result >>= 7 already did on a uint8_t. Lines 837–840 and 853 stay uncast because those fields are already unsigned, which matches the diagnostic list in #2923 exactly (only 827 and 843 are reported).

Nit (wording only)

The body says "Nine diagnostics in three commits"; the table lists 11 line sites (7 asan sites here + 3 v4l2 occurrences + the prototype) while #2923 counts 8 asan sites + 2 valgrind classes. Either reading is defensible, but the sentence and the table should use the same count.

Still open before master's Sanitizers lane is green

  • plugins/obs-outputs/mp4-mux.c.h:524 is #2922's site and #2922 is still a draft. This PR alone leaves the lane red on that one diagnostic, exactly as the body says, so the two need to land together (or #2922 should be marked ready so the queue can take both back to back).
  • The asan half's GREEN evidence is the dispatched run, not the local replay (the local gcc's range analysis differs, which the body documents). At c246a2810 that is run 40893068597, still in progress; quote its conclusion in the body before queueing so the merge group's evidence is not a promise.
  • The #2923 acceptance also asks for the mitigation so the next ratchet slice cannot land with a sanitizer-only error. That is a second PR per the body, which is fine, but #2923 stays open for it.

Local check — ./lint's Python lane on this head: all ci/test_*.py ok (an earlier failure in test_websocket_submodule.py was my checkout's plugins/obs-websocket submodule sitting off the pinned gitlink; it passes after git submodule update --init). Format/Fast Gate/Tier 2 are the PR's own lanes and were still running when I looked, so nothing to queue yet.

Coordinator: no changes requested — this is a self-review note on the maintainer's own PR. I will pick the queue step up on a later tick once the lanes and the dispatched Sanitizers run are green.

Merged via the queue into master with commit 6c5fd45 Oct 29, 2026
41 of 43 checks passed
@zackees
zackees deleted the fix/2923-sanitizer-conversions branch October 29, 2026 15:21
@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

First Sanitizers run on this branch: 40893068597 (c246a2810), tsan 🧪 green, asan 🧪 red with exactly two diagnostics left in its build log (artifact sanitize-asan):

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

Second dispatch on 562079974: 40902636208. Its result is the next comment. Note the valgrind 🧪 job of the first run is still building (~1 h on this runner), so its log is not in yet; the two valgrind diagnostics it is there to cover were reproduced and cleared locally with -D_DEBUG, as shown in the description.

@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

The macOS half of the same file, from #2922's dispatch run

While waiting on the sanitizer lane I read the macOS jobs of #2922's workflow_dispatch (40890899955, branch fix/2921-mp4-mux-conversions). Build 🧱 / macOS 🍏 (x86_64) and (arm64) failed with three diagnostics, and all three are in this PR's file, not #2922's:

plugins/obs-outputs/rtmp-hevc.c.h:827: implicit conversion loses integer precision: 'int' to 'uint8_t' [-Werror,-Wimplicit-int-conversion]
plugins/obs-outputs/rtmp-hevc.c.h:843: same
plugins/obs-outputs/rtmp-hevc.c.h:853: same       <-- not in this PR before now

mp4-mux.c.h reported nothing there, so #2922's three casts hold on AppleClang.

  • 827 and 843 were already cast in c246a2810.
  • 853 (array_completeness << 7 | NAL_unit_type & 0x3f) is added in 07c649518.

Local clang replay of the two TUs, compile database + -Wconversion -Wsign-conversion -Wfloat-conversion -Wimplicit-int-conversion-on-negation -Werror:

== obs-outputs.av1+.h.c  rc=0
== obs-outputs.hevc+.h.c rc=0

So after this PR and #2922, the three macOS jobs should have nothing left to report from plugins/obs-outputs, and the asan lane nothing left but mp4-mux.c.h:524, which is #2922's. The next Sanitizers dispatch on 07c649518 is the check.

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