-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
MDEV-36316/MDEV-36327/MDEV-36328 Debug msan fixes 10.6 #3899
base: 10.6
Are you sure you want to change the base?
Conversation
In CMAKE_BUILD_TYPE=Debug the MSAN of clang-20.1 results in MemorySanitizer: use-of-uninitialized-value on mach_read_from_2 called by rec_set_bit_field_2 (and likewise for the _1 equivalent). The non-debug builds are assumed to optimize this down such that this becomes just a setting of values.
Without this increase the mtr test case pre/post conditions will fail as the stack usage has increased under MSAN with clang-20.1. A partial success with 432K was achieved, however the 448K was needed for test cases that changed default collation. The resulting behaviour observed on smaller stack size was SEGV when a function allocated memory from the stack, and the called another function (potentially coincidenly memset - assuming common in early functions post allocation).
12611e9
to
b445f66
Compare
The function dict_process_sys_columns_rec left nth_v_col uninitialized unless it was a virtual column. This was ok as the function i_s_sys_columns_fill_table also didn't read this value unless it was a virtual column. As MSAN in clang-20 didn't follow this though, the pass by value was changed to a pass by ptr so that MSAN could detect this correctly.
…n_range ror_scan_selectivity passed an uninitialized page structure so we shouldn't be using its values. btr_estimate_n_rows_in_range doesn't use the page numbers in the tuples so these can be omitted. While ror_scan_selectivity never uses the result, however the mrr calling of records_in_range does use the result.
b445f66
to
5e9b106
Compare
#ifndef DBUG_OFF | ||
MEM_MAKE_DEFINED(rec - offs, 1); | ||
#endif | ||
mach_write_to_1(rec - offs, | ||
(mach_read_from_1(rec - offs) & ~mask) | ||
| (val << shift)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks incorrect to me. Why would we claim that all bits at rec[-offs]
are initialized when we are only overwriting some of the bits here? What would fail if this change and the similar change to rec_set_bit_field_2()
were omitted?
ulint nth_v_col, /*!< in: virtual column, its | ||
ulint* nth_v_col, /*!< in: virtual column, its | ||
sequence number (nth virtual col) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why we would need any of the changes to this file and which problem these changes would solve. We’re no longer passing a read-only parameter by value but via a pointer that is effectively read-only. Can you test again without including any of these changes?
btr_pos_t tuple1(range_start, mode1, pages->first_page); | ||
btr_pos_t tuple2(range_end, mode2, pages->last_page); | ||
btr_pos_t tuple1(range_start, mode1, 0); | ||
btr_pos_t tuple2(range_end, mode2, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would seem to be the actual fix. ~0ULL
might be a safer value, but I think that 0 should be OK as well, because the smallest possible index page number is 3.
Description
Various fixing to allow a Debug MSAN with Clang-20 to pass tests.
See individual commit messages for details.
Release Notes
How can this PR be tested?
Basing the PR against the correct MariaDB version
main
branch.PR quality check