Skip to content

Conversation

@dr-m
Copy link
Contributor

@dr-m dr-m commented Dec 23, 2025

  • The Jira issue number for this PR is: MDEV-38419

Description

clang++-21 -fsanitize=memory is flagging more errors than its predecessors. Here I am trying to fix some root causes of it, by making our code prettier. As far as I can tell, this is not fixing any actual cases of memory being uninitialized, only making the code a little simpler.
fil_space_t::free_page(): Turn a parameter into a template parameter, and remove some duplicated code. This fixes an error that was flagged by clang++-21 -fsanitize=memory in buf_page_create().

fseg_create(): Merge the parameter reserved_extent to n_reserved. This fixes an error about n_reserved being uninitialized.

fseg_alloc_free_page_low(): Simplify a debug assertion.

flst_add_last(), flst_remove(): Reduce the scope of a conditionally initialized variable.

Even after these fixes, the server would fail to bootstrap with this build variant. I got a little further by adding

#if defined __clang__ && __has_feature(memory_sanitizer)
__attribute__((optnone)) // Work around an issue with clang-21
#endif

to several functions. But I don’t think this is the correct solution; we must file a clang bug report, with some reduced input that reproduces the issue.

Release Notes

N/A

How can this PR be tested?

cmake -DWITH_MSAN=ON build using clang-21, and debug the bootstrap failures with mysql-test/mtr --boot-rr main.1st.

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

fil_space_t::free_page(): Turn a parameter into a template parameter,
and remove some duplicated code. This fixes an error that was flagged
by clang++-21 -fsanitize=memory in buf_page_create().

fseg_create(): Merge the parameter reserved_extent to n_reserved.
This fixes an error about n_reserved being uninitialized.

fseg_alloc_free_page_low(): Simplify a debug assertion.

flst_add_last(), flst_remove(): Reduce the scope of a conditionally
initialized variable.
@dr-m dr-m requested a review from Thirunarayanan December 23, 2025 10:15
@dr-m dr-m self-assigned this Dec 23, 2025
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Development

Successfully merging this pull request may close these issues.

3 participants