Skip to content

Commit d247d64

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 cdaa1d7 commit d247d64

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
@@ -1457,6 +1457,7 @@ buf_block_init(
14571457
block->frame = frame;
14581458

14591459
block->page.buf_pool_index = buf_pool_index(buf_pool);
1460+
block->page.flush_type = BUF_FLUSH_LRU;
14601461
block->page.state = BUF_BLOCK_NOT_USED;
14611462
block->page.buf_fix_count = 0;
14621463
block->page.io_fix = BUF_IO_NONE;
@@ -5130,6 +5131,7 @@ buf_page_init_low(
51305131
bpage->flush_type = BUF_FLUSH_LRU;
51315132
bpage->io_fix = BUF_IO_NONE;
51325133
bpage->buf_fix_count = 0;
5134+
bpage->old = 0;
51335135
bpage->freed_page_clock = 0;
51345136
bpage->access_time = 0;
51355137
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
}
@@ -56,7 +56,7 @@ mach_write_to_2(
5656
ulint n) /*!< in: ulint integer to be stored */
5757
{
5858
ut_ad(b);
59-
ut_ad((n | 0xFFFFUL) <= 0xFFFFUL);
59+
ut_ad((n & ~0xFFFFUL) == 0);
6060

6161
b[0] = (byte)(n >> 8);
6262
b[1] = (byte)(n);
@@ -132,7 +132,7 @@ mach_write_to_3(
132132
ulint n) /*!< in: ulint integer to be stored */
133133
{
134134
ut_ad(b);
135-
ut_ad((n | 0xFFFFFFUL) <= 0xFFFFFFUL);
135+
ut_ad((n & ~0xFFFFFFUL) == 0);
136136

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

storage/xtradb/buf/buf0buf.cc

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

11341134
block->page.buf_pool_index = buf_pool_index(buf_pool);
1135+
block->page.flush_type = BUF_FLUSH_LRU;
11351136
block->page.state = BUF_BLOCK_NOT_USED;
11361137
block->page.buf_fix_count = 0;
11371138
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)