Skip to content

Fix CI Python version on ubuntu-26.04 and WavWriter zero-byte write UB - #734

Open
atommarvel wants to merge 1 commit into
daisyaudio:masterfrom
atommarvel:fix/ci-ubuntu-26-04-and-wavwriter-ub
Open

atommarvel wants to merge 1 commit into
daisyaudio:masterfrom
atommarvel:fix/ci-ubuntu-26-04-and-wavwriter-ub

Conversation

@atommarvel

Copy link
Copy Markdown

NOTICE

This fix should fix the CI failures that new PRs are seeing in the checks.
Beyond this section, this PR's body and the code changes are fully written by AI. My day job is Android development so I currently don't have the knowledge to vet these changes deeply.

Summary

Fixes two CI failures triggered after ubuntu-latest moved to ubuntu-26.04 (observed on #732 and #733):

  1. Update Python setup in Build / build-makefile (.github/workflows/build.yml):

    • actions/setup-python@v2 with python-version: 3.8 fails on ubuntu-26.04 (Version 3.8 with arch x64 not found).
    • Updated to actions/setup-python@v5 with python-version: '3.x' (ci/build_examples.py only uses Python 3 stdlib modules).
  2. Fix out-of-bounds std::vector indexing UB on 0-byte WavWriter tail flush (src/util/WavWriter.h, tests/FatFsMock.cpp):

    • When recording ends exactly on the first half-buffer boundary (wptr_ == cap_point), WavWriter::SaveFile() flushed the half-buffer via Write()and then computed remaining_size == 0, calling f_write(&fp_, ..., 0, &bw).
    • In tests/FatFsMock.cpp, f_write evaluated std::memcpy(&state.file_data[start_idx], buff, 0) with start_idx == state.file_data.size(), triggering SIGABRT under standard-library bounds assertions (_GLIBCXX_ASSERTIONS enabled on ubuntu-26.04) in saveFile_flush0HalfOnce, saveFile_s32StereoFlush0HalfOnce, and saveFile_s16MonoFlush0HalfOnce.
    • Guarded the partial-tail f_write call in WavWriter::SaveFile() with if(remaining_size > 0) and guarded std::memcpy in FatFsMock.cpp with if(btw > 0).

Testing

  • Reproduced the saveFile_flush0HalfOnce abort locally using -D_LIBCPP_ENABLE_ASSERTIONS=1 (assertion __n < size() failed, exit 134).
  • Re-ran all 13 util_WavWriter tests in tests/WavWriter_gtest.cpp with -D_LIBCPP_ENABLE_ASSERTIONS=1 -fsanitize=address,undefined — all 13 pass.
  • Verified direct zero-byte f_write at EOF in FatFsMock.cpp with assertions + ASan/UBSan enabled.

uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: '3.x'

@atommarvel atommarvel Nov 21, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not the biggest fan of not specifying the exact version. I would probably go with 3.14 which is the native Python version for Ubuntu 26.04 LTS. Looks like 3.14 has support until Oct 2030. I'll let the reviewer decide what direction to take though.

Comment thread src/util/WavWriter.h

uint8_t *base = reinterpret_cast<uint8_t *>(transfer_buff);
f_write(&fp_, base + offset_bytes, remaining_size, &bw);
if(remaining_size > 0)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Seems like technically this change isn't required for the CI fix, but it seems like a value add.

@stephenhensley

Copy link
Copy Markdown
Collaborator

Hey, thanks for the PR. I was going to address this today; you beat me to it!

I'd like the python version to be tagged at a real version. If 3.14 works, you can pin it there.

The other changes are fine.
f_write actually does a little bit more than I thought when btw == 0

@github-actions

Copy link
Copy Markdown

Test Results

167 tests  ±0   167 ✅ ±0   0s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 47226d3. ± Comparison against base commit 1289a00.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants