Skip to content

Commit a68d135

Browse files
committed
MDEV-11349 (2/2) Fix some bogus-looking Valgrind warnings
buf_block_init(): Initialize buf_page_t::flush_type. For some reason, Valgrind 3.12.0 would seem to flag some bits in adjacent bitfields as uninitialized, even though only the two bits of flush_type were left uninitialized. Initialize the field to get rid of many warnings. buf_page_init_low(): Initialize buf_page_t::old. For some reason, Valgrind 3.12.0 would seem to flag all 32 bits uninitialized when buf_page_init_for_read() invokes buf_LRU_add_block(bpage, TRUE). This would trigger bogus warnings for buf_page_t::freed_page_clock being uninitialized. (The V-bits would later claim that only "old" is initialized in the 32-bit word.) Perhaps recent compilers (GCC 6.2.1 and clang 4.0.0) generate more optimized x86_64 code for bitfield operations, confusing Valgrind? mach_write_to_1(), mach_write_to_2(), mach_write_to_3(): Rewrite the assertions that ensure that the most significant bits are zero. Apparently, clang 4.0.0 would optimize expressions of the form ((n | 0xFF) <= 0x100) to (n <= 0x100). The redundant 0xFF was added in the first place in order to suppress a Valgrind warning. (Valgrind would warn about comparing uninitialized values even in the case when the uninitialized bits do not affect the result of the comparison.)
1 parent 8da33e3 commit a68d135

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

storage/innobase/buf/buf0buf.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,7 @@ buf_block_init(
11241124
block->frame = frame;
11251125

11261126
block->page.buf_pool_index = buf_pool_index(buf_pool);
1127+
block->page.flush_type = BUF_FLUSH_LRU;
11271128
block->page.state = BUF_BLOCK_NOT_USED;
11281129
block->page.buf_fix_count = 0;
11291130
block->page.io_fix = BUF_IO_NONE;
@@ -3784,6 +3785,7 @@ buf_page_init_low(
37843785
bpage->flush_type = BUF_FLUSH_LRU;
37853786
bpage->io_fix = BUF_IO_NONE;
37863787
bpage->buf_fix_count = 0;
3788+
bpage->old = 0;
37873789
bpage->freed_page_clock = 0;
37883790
bpage->access_time = 0;
37893791
bpage->newest_modification = 0;

storage/innobase/include/mach0data.ic

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mach_write_to_1(
3838
ulint n) /*!< in: ulint integer to be stored, >= 0, < 256 */
3939
{
4040
ut_ad(b);
41-
ut_ad((n | 0xFFUL) <= 0xFFUL);
41+
ut_ad((n & ~0xFFUL) == 0);
4242

4343
b[0] = (byte) n;
4444
}
@@ -68,7 +68,7 @@ mach_write_to_2(
6868
ulint n) /*!< in: ulint integer to be stored */
6969
{
7070
ut_ad(b);
71-
ut_ad((n | 0xFFFFUL) <= 0xFFFFUL);
71+
ut_ad((n & ~0xFFFFUL) == 0);
7272

7373
b[0] = (byte)(n >> 8);
7474
b[1] = (byte)(n);
@@ -131,7 +131,7 @@ mach_write_to_3(
131131
ulint n) /*!< in: ulint integer to be stored */
132132
{
133133
ut_ad(b);
134-
ut_ad((n | 0xFFFFFFUL) <= 0xFFFFFFUL);
134+
ut_ad((n & ~0xFFFFFFUL) == 0);
135135

136136
b[0] = (byte)(n >> 16);
137137
b[1] = (byte)(n >> 8);

storage/xtradb/buf/buf0buf.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,7 @@ buf_block_init(
11891189
block->frame = frame;
11901190

11911191
block->page.buf_pool_index = buf_pool_index(buf_pool);
1192+
block->page.flush_type = BUF_FLUSH_LRU;
11921193
block->page.state = BUF_BLOCK_NOT_USED;
11931194
block->page.buf_fix_count = 0;
11941195
block->page.io_fix = BUF_IO_NONE;

storage/xtradb/include/mach0data.ic

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mach_write_to_1(
3838
ulint n) /*!< in: ulint integer to be stored, >= 0, < 256 */
3939
{
4040
ut_ad(b);
41-
ut_ad((n | 0xFFUL) <= 0xFFUL);
41+
ut_ad((n & ~0xFFUL) == 0);
4242

4343
b[0] = (byte) n;
4444
}
@@ -67,7 +67,7 @@ mach_write_to_2(
6767
ulint n) /*!< in: ulint integer to be stored */
6868
{
6969
ut_ad(b);
70-
ut_ad((n | 0xFFFFUL) <= 0xFFFFUL);
70+
ut_ad((n & ~0xFFFFUL) == 0);
7171

7272
b[0] = (byte)(n >> 8);
7373
b[1] = (byte)(n);
@@ -115,7 +115,7 @@ mach_write_to_3(
115115
ulint n) /*!< in: ulint integer to be stored */
116116
{
117117
ut_ad(b);
118-
ut_ad((n | 0xFFFFFFUL) <= 0xFFFFFFUL);
118+
ut_ad((n & ~0xFFFFFFUL) == 0);
119119

120120
b[0] = (byte)(n >> 16);
121121
b[1] = (byte)(n >> 8);

0 commit comments

Comments
 (0)