MDEV-38419: Fix some clang-21 -fsanitize=memory failures #4495
+41
−34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
clang++-21 -fsanitize=memoryis 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 byclang++-21 -fsanitize=memoryinbuf_page_create().fseg_create(): Merge the parameterreserved_extentton_reserved. This fixes an error aboutn_reservedbeing 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
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=ONbuild usingclang-21, and debug the bootstrap failures withmysql-test/mtr --boot-rr main.1st.Basing the PR against the correct MariaDB version
mainbranch.PR quality check