fix(libwebrtc): compile libfvad with -fno-sanitize=shift for the sanitizer job #15927

Merged
xXPBSXx merged 1 commit from upstream-pr/15927 into main 2026-11-08 07:07:26 +00:00
xXPBSXx commented 2026-11-05 00:51:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-11-05T00:51:31Z.


What

guest_webrtc_vad fails in the nightly Sanitizers runs of 2026-11-02, 2026-11-03 and 2026-11-04 with 3rdparty/libfvad/src/signal_processing/resample_by_2_internal.c:141:37: runtime error: left shift of negative value -32490. The sanitizer build uses -fno-sanitize-recover=undefined, so the first report stops the test.

The line is in the 3rdparty/libfvad submodule, pinned to 532ab666c20d3cfda38bca63abbb0f152706c369, which is the newest commit of the upstream repository (2024-02-19); upstream has no fix. The code shifts a negative 16-bit sample left, which is undefined in C. libfvad already marks its functions that overflow with RTC_NO_SANITIZE("signed-integer-overflow") (src/common.h:29, used at resample_by_2_internal.c:31, :127 and :206 and at vad/vad_core.c:115), but not this shift.

This PR adds target_compile_options(fvad PRIVATE $<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-fno-sanitize=shift>) after the fvad target is created in core/libs/CMakeLists.txt. The consequence, stated plainly: UBSan no longer checks shifts in libfvad. Its other checks, and every other target, stay on, and the generated code is unchanged (outside the sanitizer builds the flag has no effect). A technical debt entry in docs/dev/debt/libwebrtc.md says so.

There is no precedent in the repository for -fno-sanitize on a third-party target (git grep on b11c7bf84f). The nearest cases are the global -fno-sanitize=function in CMakeLists.txt:110 and the no_sanitize("address") attributes on three functions of our own code. I did not take two other routes: a line in .github/sanitizer-known-failures.txt would be permanent, because there is no upstream fix to wait for (the existing guest_vorbis_dec line pointed at an upstream fix, #11480), and an UBSan suppression file for the test is not measured and has no precedent here. The repository has no mechanism to patch a submodule's files.

Tested

Ubuntu 24.04, GCC 13.3, ASan + UBSan configured as in sanitizers.yml (-fno-sanitize-recover=undefined), ASAN_OPTIONS=detect_leaks=0, UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1, on 2026-11-04 from 16:50 UTC to 16:51 UTC, on main b11c7bf84f5d2f636ff60166cc3371bd071e24d5 plus the change:

  • With the change: guest_webrtc_vad Passed in 3 of 3 runs; the compile command of resample_by_2_internal.c contains -fno-sanitize=shift.
  • core/libs/CMakeLists.txt from main (red): Failed in 3 of 3 runs with the message above, and the compile command does not contain the flag.
  • Change restored: Passed in 3 of 3 runs. cmake and ninja exited 0 in every arm.
  • These runs used an earlier version of this commit whose core/libs/CMakeLists.txt is byte for byte the same file (blob 90e03222b390362fe2563db13d464656d2f26264); only the debt entry was reworded and moved.

MinGW GCC 15.2.0 (WinLibs) on Windows 10, 2026-11-04 at 17:08 UTC: cmake -S . -B build exited 0, ninja -C build fvad exited 0, and the compile command of resample_by_2_internal.c contains -fno-sanitize=shift.

python -I tools/check_conventions.py --base b11c7bf84f5d2f636ff60166cc3371bd071e24d5 passed at 17:10 UTC; git diff --check is clean.

Not run: Clang and AppleClang (the expression lists them; no Clang was available here), MSVC (the expression leaves it out), and the nightly's own GCC 15 on ubuntu-latest.

Overlap

Checked against main d63781e9ce with the 1879 open PRs listed at 22:51 UTC on 2026-11-04 (scan from 22:50 UTC on 2026-11-04 to 00:03 UTC on 2026-11-05); the changed files of each PR come from git diff --name-only against its merge base. 67 PRs change core/libs/CMakeLists.txt, 34 change docs/dev/debt/libwebrtc.md and 2 change .github/sanitizer-known-failures.txt; together they are 102 PRs. No open PR changes 3rdparty/libfvad or core/libs/tests/GuestWebrtcVad.cpp, and no open PR title mentions fvad, webrtc_vad or resample_by_2. #15905 had no fetchable ref at that time; its file list from the API (core/libs/tests/GuestPad.cpp) does not touch these files. Measured against this head with git merge-tree: 85 are clean. The other 17 also conflict with main alone, so this PR does not cause any of them. The branch is based on b11c7bf84f; against current main 41eee370ea9a946b1a78699461042baa4f812aa8 (checked on 2026-11-05 at 00:19 UTC) it merges cleanly.

#15165 adds a guest_webrtc_vad line to .github/sanitizer-known-failures.txt. It does not conflict with this PR, which does not touch that file, but once both are merged the test passes and the line would be listed as known but passed. Depends on: none.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5164130840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15927). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-11-05T00:51:31Z. --- ### What `guest_webrtc_vad` fails in the nightly Sanitizers runs of 2026-11-02, 2026-11-03 and 2026-11-04 with `3rdparty/libfvad/src/signal_processing/resample_by_2_internal.c:141:37: runtime error: left shift of negative value -32490`. The sanitizer build uses `-fno-sanitize-recover=undefined`, so the first report stops the test. The line is in the `3rdparty/libfvad` submodule, pinned to `532ab666c20d3cfda38bca63abbb0f152706c369`, which is the newest commit of the upstream repository (2024-02-19); upstream has no fix. The code shifts a negative 16-bit sample left, which is undefined in C. libfvad already marks its functions that overflow with `RTC_NO_SANITIZE("signed-integer-overflow")` (`src/common.h:29`, used at `resample_by_2_internal.c:31`, `:127` and `:206` and at `vad/vad_core.c:115`), but not this shift. This PR adds `target_compile_options(fvad PRIVATE $<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-fno-sanitize=shift>)` after the `fvad` target is created in `core/libs/CMakeLists.txt`. The consequence, stated plainly: UBSan no longer checks shifts in libfvad. Its other checks, and every other target, stay on, and the generated code is unchanged (outside the sanitizer builds the flag has no effect). A technical debt entry in `docs/dev/debt/libwebrtc.md` says so. There is no precedent in the repository for `-fno-sanitize` on a third-party target (`git grep` on `b11c7bf84f`). The nearest cases are the global `-fno-sanitize=function` in `CMakeLists.txt:110` and the `no_sanitize("address")` attributes on three functions of our own code. I did not take two other routes: a line in `.github/sanitizer-known-failures.txt` would be permanent, because there is no upstream fix to wait for (the existing `guest_vorbis_dec` line pointed at an upstream fix, #11480), and an UBSan suppression file for the test is not measured and has no precedent here. The repository has no mechanism to patch a submodule's files. ### Tested Ubuntu 24.04, GCC 13.3, ASan + UBSan configured as in `sanitizers.yml` (`-fno-sanitize-recover=undefined`), `ASAN_OPTIONS=detect_leaks=0`, `UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1`, on 2026-11-04 from 16:50 UTC to 16:51 UTC, on `main` `b11c7bf84f5d2f636ff60166cc3371bd071e24d5` plus the change: - With the change: `guest_webrtc_vad` Passed in 3 of 3 runs; the compile command of `resample_by_2_internal.c` contains `-fno-sanitize=shift`. - `core/libs/CMakeLists.txt` from main (red): Failed in 3 of 3 runs with the message above, and the compile command does not contain the flag. - Change restored: Passed in 3 of 3 runs. cmake and ninja exited 0 in every arm. - These runs used an earlier version of this commit whose `core/libs/CMakeLists.txt` is byte for byte the same file (blob `90e03222b390362fe2563db13d464656d2f26264`); only the debt entry was reworded and moved. MinGW GCC 15.2.0 (WinLibs) on Windows 10, 2026-11-04 at 17:08 UTC: `cmake -S . -B build` exited 0, `ninja -C build fvad` exited 0, and the compile command of `resample_by_2_internal.c` contains `-fno-sanitize=shift`. `python -I tools/check_conventions.py --base b11c7bf84f5d2f636ff60166cc3371bd071e24d5` passed at 17:10 UTC; `git diff --check` is clean. Not run: Clang and AppleClang (the expression lists them; no Clang was available here), MSVC (the expression leaves it out), and the nightly's own GCC 15 on ubuntu-latest. ### Overlap Checked against main d63781e9ce826dd5445b35b91960bb576f4834ae with the 1879 open PRs listed at 22:51 UTC on 2026-11-04 (scan from 22:50 UTC on 2026-11-04 to 00:03 UTC on 2026-11-05); the changed files of each PR come from `git diff --name-only` against its merge base. 67 PRs change `core/libs/CMakeLists.txt`, 34 change `docs/dev/debt/libwebrtc.md` and 2 change `.github/sanitizer-known-failures.txt`; together they are 102 PRs. No open PR changes `3rdparty/libfvad` or `core/libs/tests/GuestWebrtcVad.cpp`, and no open PR title mentions `fvad`, `webrtc_vad` or `resample_by_2`. #15905 had no fetchable ref at that time; its file list from the API (`core/libs/tests/GuestPad.cpp`) does not touch these files. Measured against this head with `git merge-tree`: 85 are clean. The other 17 also conflict with main alone, so this PR does not cause any of them. The branch is based on `b11c7bf84f`; against current main `41eee370ea9a946b1a78699461042baa4f812aa8` (checked on 2026-11-05 at 00:19 UTC) it merges cleanly. #15165 adds a `guest_webrtc_vad` line to `.github/sanitizer-known-failures.txt`. It does not conflict with this PR, which does not touch that file, but once both are merged the test passes and the line would be listed as known but passed. Depends on: none. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15927
No description provided.