Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.4.5
-
None
-
BUILD/compile-pentium64-valgrind-max
Description
mtr --valgrind main.xa_binlog
==10964== Syscall param pwrite64(buf) points to uninitialised byte(s)
==10964== at 0x4E4CA83: ??? (in /lib64/libpthread-2.26.so)
==10964== by 0x1064216: SyncFileIO::execute(IORequest const&) (os0file.cc:1481)
==10964== by 0x1067E32: os_file_io(IORequest const&, int, void*, unsigned long, u
nsigned long, dberr_t*) (os0file.cc:4726)
==10964== by 0x1068348: os_file_pwrite(IORequest const&, int, unsigned char const*, unsigned long, unsigned long, dberr_t*) (os0file.cc:4811)
==10964== by 0x10684AC: os_file_write_func(IORequest const&, char const*, int, void const*, unsigned long, unsigned long) (os0file.cc:4842)
==10964== by 0x106B477: os_aio_func(IORequest&, unsigned long, char const*, pfs_os_file_t, void*, unsigned long, unsigned long, bool, fil_node_t*, void*) (os0file.cc:6504)
==10964== by 0x12B7E87: pfs_os_aio_func(IORequest&, unsigned long, char const*, pfs_os_file_t, void*, unsigned long, unsigned long, bool, fil_node_t*, void*, char const*, unsigned int) (os0file.ic:254)
==10964== by 0x12C5319: fil_io(IORequest const&, bool, page_id_t, unsigned long, unsigned long, unsigned long, void*, void*, bool) (fil0fil.cc:4299)
==10964== by 0x103CAC5: log_write_buf(unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (log0log.cc:759)
==10964== by 0x103D47C: log_write_up_to(unsigned long, bool, bool) (log0log.cc:1009)
==10964== by 0x11B3D91: trx_flush_log_if_needed_low(unsigned long) (trx0trx.cc:1201)
==10964== by 0x11B3DDA: trx_flush_log_if_needed(unsigned long, trx_t*) (trx0trx.cc:1223)
==10964== by 0x11B671D: trx_prepare(trx_t*) (trx0trx.cc:2075)
==10964== by 0x11B677B: trx_prepare_for_mysql(trx_t*) (trx0trx.cc:2087)
==10964== by 0xF9D0BA: innobase_xa_prepare(handlerton*, THD*, bool) (ha_innodb.cc:16789)
=10964== by 0xBA3E11: prepare_or_error(handlerton*, THD*, bool) (handler.cc:1223)
==10964== Address 0x1166e1e4 is in a rw- anonymous segment
- saving '/home/my/maria-10.5/mysql-test/var/log/main.xa_binlog-innodb/' to '/home/my/maria-10.5/mysql-test/var/log/main.xa_binlog-innodb/'
***Warnings generated in error logs during shutdown after running tests: main.xa_binlog
==22104== Thread 10:
==22104== Uninitialised byte(s) found during client check request
==22104== at 0x12422C9: buf_dblwr_add_to_batch(buf_page_t*) (buf0dblwr.cc:1147)
==22104== by 0x124A620: buf_flush_write_block_low(buf_page_t*, buf_flush_t, bool) (buf0flu.cc:1063)
==22104== by 0x124AD08: buf_flush_page(buf_pool_t*, buf_page_t*, buf_flush_t, bool) (buf0flu.cc:1211)
==22104== by 0x124B6A0: buf_flush_try_neighbors(page_id_t, buf_flush_t, unsigned long, unsigned long) (buf0flu.cc:1437)
==22104== by 0x124BADC: buf_flush_page_and_try_neighbors(buf_page_t*, buf_flush_t, unsigned long, unsigned long*) (buf0flu.cc:1511)
==22104== by 0x124C9C9: buf_do_flush_list_batch(buf_pool_t*, unsigned long, unsigned long) (buf0flu.cc:1770)
==22104== by 0x124D0E0: buf_flush_batch(buf_pool_t*, buf_flush_t, unsigned long, unsigned long, flush_counters_t*) (buf0flu.cc:1840)
==22104== by 0x124D798: buf_flush_do_batch(buf_pool_t*, buf_flush_t, unsigned long, unsigned long, flush_counters_t*) (buf0flu.cc:1998)
==22104== by 0x124DA4E: buf_flush_lists(unsigned long, unsigned long, unsigned long*) (buf0flu.cc:2100)
==22104== by 0x12526D6: buf_flush_page_cleaner_coordinator (buf0flu.cc:3256)
==22104== by 0x4E42568: start_thread (in /lib64/libpthread-2.26.so)
==22104== by 0x6ECBA2E: clone (in /lib64/libc-2.26.so)
==22104== Address 0x10ef4249 is 585 bytes inside a frame of size 16,384 client-defined
==22104== at 0x1227997: buf_block_init(buf_pool_t*, buf_block_t*, unsigned char*) (buf0buf.cc:1511)
==22104== by 0x1227E28: buf_chunk_init(buf_pool_t*, buf_chunk_t*, unsigned long) (buf0buf.cc:1657)
==22104== by 0x12288CD: buf_pool_init_instance(buf_pool_t*, unsigned long, unsigned long) (buf0buf.cc:1891)
==22104== by 0x12292E1: buf_pool_init(unsigned long, unsigned long) (buf0buf.cc:2087)
==22104== by 0x116C25A: srv_start(bool) (srv0start.cc:1512)
==22104== by 0xF83BA0: innodb_init(void*) (ha_innodb.cc:4127)
==22104== by 0xBA2FC4: ha_initialize_handlerton(st_plugin_int*) (handler.cc:550)
==22104== by 0x8A3030: plugin_initialize(st_mem_root*, st_plugin_int*, int*, char**, bool) (sql_plugin.cc:1437)
==22104== by 0x8A3C2C: plugin_init(int*, char**, int) (sql_plugin.cc:1719)
==22104== by 0x75C827: init_server_components() (mysqld.cc:5037)
==22104== by 0x75D99E: mysqld_main(int, char**) (mysqld.cc:5566)
==22104== by 0x7524A6: main (main.cc:25)
==22104== Syscall param io_submit(PWRITE) points to uninitialised byte(s)
==22104== at 0x5E6A787: io_submit (in /lib64/libaio.so.1.0.1)
==22104== by 0x106529A: AIO::linux_dispatch(Slot*) (os0file.cc:2035)
==22104== by 0x106B5B1: os_aio_func(IORequest&, unsigned long, char const*, pfs_os_file_t, void*, unsigned long, unsigned long, bool, fil_node_t*, void*) (os0file.cc:6548)
==22104== by 0x12B7E87: pfs_os_aio_func(IORequest&, unsigned long, char const*, pfs_os_file_t, void*, unsigned long, unsigned long, bool, fil_node_t*, void*, char const*, unsigned int) (os0file.ic:254)
==22104== by 0x12C5319: fil_io(IORequest const&, bool, page_id_t, unsigned long, unsigned long, unsigned long, void*, void*, bool) (fil0fil.cc:4299)
==22104== by 0x1241937: buf_dblwr_write_block_to_datafile(buf_page_t const*, bool) (buf0dblwr.cc:938)
==22104== by 0x1241F15: buf_dblwr_flush_buffered_writes() (buf0dblwr.cc:1082)
==22104== by 0x124D5E7: buf_flush_end(buf_pool_t*, buf_flush_t) (buf0flu.cc:1931)
==22104== by 0x124D7A9: buf_flush_do_batch(buf_pool_t*, buf_flush_t, unsigned long, unsigned long, flush_counters_t*) (buf0flu.cc:2000)
==22104== by 0x124DA4E: buf_flush_lists(unsigned long, unsigned long, unsigned long*) (buf0flu.cc:2100)
==22104== by 0x12526D6: buf_flush_page_cleaner_coordinator (buf0flu.cc:3256)
==22104== by 0x4E42568: start_thread (in /lib64/libpthread-2.26.so)
==22104== by 0x6ECBA2E: clone (in /lib64/libc-2.26.so)
==22104== Address 0x10ef4249 is 585 bytes inside a frame of size 16,384 client-defined
==22104== at 0x1227997: buf_block_init(buf_pool_t*, buf_block_t*, unsigned char*) (buf0buf.cc:1511)
==22104== by 0x1227E28: buf_chunk_init(buf_pool_t*, buf_chunk_t*, unsigned long) (buf0buf.cc:1657)
==22104== by 0x12288CD: buf_pool_init_instance(buf_pool_t*, unsigned long, unsigned long) (buf0buf.cc:1891)
==22104== by 0x12292E1: buf_pool_init(unsigned long, unsigned long) (buf0buf.cc:2087)
==22104== by 0x116C25A: srv_start(bool) (srv0start.cc:1512)
==22104== by 0xF83BA0: innodb_init(void*) (ha_innodb.cc:4127)
==22104== by 0xBA2FC4: ha_initialize_handlerton(st_plugin_int*) (handler.cc:550)
==22104== by 0x8A3030: plugin_initialize(st_mem_root*, st_plugin_int*, int*, char**, bool) (sql_plugin.cc:1437)
==22104== by 0x8A3C2C: plugin_init(int*, char**, int) (sql_plugin.cc:1719)
==22104== by 0x75C827: init_server_components() (mysqld.cc:5037)
==22104== by 0x75D99E: mysqld_main(int, char**) (mysqld.cc:5566)
==22104== by 0x7524A6: main (main.cc:25)
Attachments
Issue Links
- is part of
-
MDEV-20310 valgrind bugs found in 10.5
-
- Closed
-
- relates to
-
MDEV-7974 backport fix for mysql bug#12161 (XA and binlog)
-
- Closed
-
-
MDEV-20333 Uninitialized memory used in buf_flush_insert_into_flush_list
-
- Closed
-
I can repeat some Valgrind warnings when running main.xa_binlog. First, many Conditional jump or move depends on uninitialised value(s) outside InnoDB, related to SSL initialization. Here is the first one:
10.5 f6e386f00b4e50174758d3707706f0d1288baeb3
Thread 1 received signal SIGTRAP, Trace/breakpoint trap.
0x00000000052542e3 in ?? () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
(gdb) bt
#0 0x00000000052542e3 in ?? ()
from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#1 0x00000000052551fb in RAND_DRBG_generate ()
from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#2 0x0000000005256621 in ?? ()
from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#3 0x0000000005254a0a in RAND_DRBG_instantiate ()
from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#4 0x0000000005255938 in ?? ()
from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#5 0x0000000005255cca in RAND_DRBG_get0_public ()
from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#6 0x0000000005255cf0 in ?? ()
from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#7 0x0000000005046be3 in SSL_CTX_new ()
from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#8 0x0000000000b4fe52 in new_VioSSLFd (
key_file=0x58adfa0 "/mariadb/10.5/mysql-test/std_data/server-key.pem",
cert_file=0x58adef1 "/mariadb/10.5/mysql-test/std_data/server-cert.pem",
ca_file=0x58ade4f "/mariadb/10.5/mysql-test/std_data/cacert.pem",
ca_path=0x0, cipher=<optimized out>, is_client_method=0 '\000',
error=<optimized out>, crl_file=<optimized out>,
crl_path=<optimized out>, tls_version=<optimized out>)
at /mariadb/10.5/vio/viosslfactories.c:251
#9 0x0000000000b505f5 in new_VioSSLAcceptorFd (key_file=0xb276860 "",
cert_file=0xb90ce30 "", ca_file=0xb276957 "{800-90A DRBG\200",
ca_path=0x0, cipher=0x0, error=<optimized out>, crl_file=0x0,
crl_path=0x0, tls_version=14) at /mariadb/10.5/vio/viosslfactories.c:413
#10 0x000000000063ba04 in init_ssl () at /mariadb/10.5/sql/mysqld.cc:4626
#11 mysqld_main (argc=<optimized out>, argv=<optimized out>)
at /mariadb/10.5/sql/mysqld.cc:5632
#12 0x00000000055a509b in __libc_start_main (
main=0x636770 <main(int, char**)>, argc=25, argv=0x1fff000378,
init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x1fff000368) at ../csu/libc-start.c:308
#13 0x00000000006366aa in _start ()
Then, a bogus warning, apparently because Valgrind is not compatible with the optimized code generated by my compiler clang-8:
==20837== Conditional jump or move depends on uninitialised value(s)
==20837== at 0xD6D00B: mach_write_to_2 (mach0data.ic:58)
==20837== by 0xD6D00B: rec_set_bit_field_2 (rem0rec.ic:220)
==20837== by 0xD6D00B: rec_set_n_fields_old (rem0rec.ic:431)
==20837== by 0xD6D00B: rec_convert_dtuple_to_rec_old (rem0rec.cc:1419)
==20837== by 0xD6D00B: rec_convert_dtuple_to_rec(unsigned char*, dict_index_t const*, dtuple_t const*, unsigned long) (rem0rec.cc:1765)
==20837== by 0xE86D06: page_cur_tuple_insert(page_cur_t*, dtuple_t const*, dict_index_t*, unsigned long**, mem_block_info_t**, unsigned long, mtr_t*) (page0cur.ic:272)
The code is
ut_ad((n & ~0xFFFFUL) == 0);
After I removed -O2 from the CMAKE_CXX_FLAGS, this bogus warning went away, and the first InnoDB issue (after the SSL initialization) instead was the reported one:
Syscall param pwrite64(buf) points to uninitialised byte(s)
…
#0 __libc_pwrite64 (offset=141312, count=512, buf=0xce72000, fd=11)
at ../sysdeps/unix/sysv/linux/pwrite64.c:29
#1 __libc_pwrite64 (fd=11, buf=0xce72000, count=512, offset=141312)
at ../sysdeps/unix/sysv/linux/pwrite64.c:27
#2 0x0000000001143014 in SyncFileIO::execute (this=0xd0948c8, request=...)
at /mariadb/10.5/storage/innobase/os/os0file.cc:1481
#3 0x000000000114e5ee in os_file_io (in_type=..., file=11, buf=0xce72000,
n=512, offset=141312, err=0xd094f2c)
at /mariadb/10.5/storage/innobase/os/os0file.cc:4726
#4 0x0000000001147a29 in os_file_pwrite (type=..., file=11,
buf=0xce72000 "\200", n=512, offset=141312, err=0xd094f2c)
at /mariadb/10.5/storage/innobase/os/os0file.cc:4810
#5 0x0000000001147509 in os_file_write_func (type=...,
name=0xb779460 "./ib_logfile0", file=11, buf=0xce72000, offset=141312,
n=512) at /mariadb/10.5/storage/innobase/os/os0file.cc:4842
#6 0x000000000114bc59 in os_aio_func (type=..., mode=24,
name=0xb779460 "./ib_logfile0", file=..., buf=0xce72000, offset=141312,
n=512, read_only=false, m1=0x10b7ea90, m2=0x0)
at /mariadb/10.5/storage/innobase/os/os0file.cc:6504
#7 0x000000000143370d in pfs_os_aio_func (type=..., mode=24,
name=0xb779460 "./ib_logfile0", file=..., buf=0xce72000, offset=141312,
n=512, read_only=false, m1=0x10b7ea90, m2=0x0,
src_file=0x1848a26 "/mariadb/10.5/storage/innobase/fil/fil0fil.cc",
src_line=4304) at /mariadb/10.5/storage/innobase/include/os0file.ic:253
#8 0x0000000001433044 in fil_io (type=..., sync=true, page_id=...,
zip_size=16384, byte_offset=10240, len=512, buf=0xce72000, message=0x0,
ignore_missing_space=false)
at /mariadb/10.5/storage/innobase/fil/fil0fil.cc:4299
#9 0x0000000001111aeb in log_write_buf (buf=0xce72000 "\200", len=512,
pad_len=0, start_lsn=147968, new_data_offset=58)
at /mariadb/10.5/storage/innobase/log/log0log.cc:759
#10 0x0000000001110e7a in log_write_up_to (lsn=148282, flush_to_disk=true,
rotate_key=false) at /mariadb/10.5/storage/innobase/log/log0log.cc:1009
#11 0x00000000012e7557 in trx_flush_log_if_needed_low (lsn=148282)
at /mariadb/10.5/storage/innobase/trx/trx0trx.cc:1201
#12 0x00000000012e493b in trx_flush_log_if_needed (lsn=148282, trx=0xc172170)
at /mariadb/10.5/storage/innobase/trx/trx0trx.cc:1223
#13 0x00000000012e53d4 in trx_prepare (trx=0xc172170)
at /mariadb/10.5/storage/innobase/trx/trx0trx.cc:2075
#14 0x00000000012e51b2 in trx_prepare_for_mysql (trx=0xc172170)
at /mariadb/10.5/storage/innobase/trx/trx0trx.cc:2087
#15 0x0000000001054938 in innobase_xa_prepare (hton=0xb4f0168, thd=0xb3723e8,
prepare_trx=true)
at /mariadb/10.5/storage/innobase/handler/ha_innodb.cc:16789
#16 0x0000000000c48ac1 in prepare_or_error (ht=0xb4f0168, thd=0xb3723e8,
all=true) at /mariadb/10.5/sql/handler.cc:1223
#17 0x0000000000c488e1 in ha_prepare (thd=0xb3723e8)
at /mariadb/10.5/sql/handler.cc:1261
#18 0x0000000000b705be in trans_xa_prepare (thd=0xb3723e8)
at /mariadb/10.5/sql/xa.cc:500
#19 0x00000000008d4945 in mysql_execute_command (thd=0xb3723e8)
at /mariadb/10.5/sql/sql_parse.cc:5915
#20 0x00000000008c22b0 in mysql_parse (thd=0xb3723e8,
rawbuf=0x17e14310 "XA PREPARE 'xatest'", length=19,
parser_state=0xd09bcb8, is_com_multi=false, is_next_command=false)
at /mariadb/10.5/sql/sql_parse.cc:7868
…
(gdb) frame 2
#2 0x0000000001143014 in SyncFileIO::execute (this=0xd0948c8, request=...)
at /mariadb/10.5/storage/innobase/os/os0file.cc:1481
(gdb) p *this
$1 = {m_fh = 11, m_buf = 0xce72000, m_n = 512, m_offset = 141312}
(gdb) monitor get_vbits 0xce72000 512
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 000000ff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ff000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 ffffffff
(gdb)
The uninitialized bytes appear to be the redo log block checksum (the last 4 bytes), as well as the 124 bytes in the payload area:
p/x ((char*)m_buf)[191]@124
$4 = {0x0 <repeats 122 times>, 0x1f, 0x0}
This appears to be right after the XID xatest:
(gdb) p *(char*)m_buf@m_n
$5 = "\200\000\001\"\001:\000\021\000\000\000\004\000\000\000\000\000\236\000\n\t\222\000\r\000\000\000\000\000\000\200\000\000\000\000\000\000\236\000\201\063\001\066\000\r\000\000\000\000\000\000\200\000\000\000\000\000\000\031\000\201\067\000\000\000\000\036\002\000\201\067\000(\202\303\002\000\201\067\000*\202\303\002\000\201\067\002\033\202\303\024\000\201\067\000\b\v\000\024\004\200\000\000\001\037\246\005\003\000\003\000\001\200\004\200\006\200\a\000c#\000\005\005\200\000\000\001\000\000\000\000\000\036\203\000\000\001\067\002\303\002\000\201\067\000\070\005\001\000\201\067\002\035\001\004\000\201\067\002\067\001\004\000\201\067\002;\006\004\000\201\067\002?\000\036\000\201\067\002C\000\200xatest", '\000' <repeats 122 times>, "\037", '\000' <repeats 194 times>, "\335\300\273!"
The following change fixes this, and also reduces the redo log volume somewhat:
diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc
index 6267a8edd53..dde95dc1bce 100644
--- a/storage/innobase/trx/trx0undo.cc
+++ b/storage/innobase/trx/trx0undo.cc
@@ -662,6 +662,10 @@ trx_undo_write_xid(
const XID* xid, /*!< in: X/Open XA Transaction Identification */
mtr_t* mtr) /*!< in: mtr */
{
+ ut_ad(xid->gtrid_length >= 0);
+ ut_ad(xid->bqual_length >= 0);
+ ut_ad(xid->gtrid_length + xid->bqual_length < XIDDATASIZE);
+
mlog_write_ulint(log_hdr + TRX_UNDO_XA_FORMAT,
static_cast<ulint>(xid->formatID),
MLOG_4BYTES, mtr);
@@ -673,10 +677,13 @@ trx_undo_write_xid(
mlog_write_ulint(log_hdr + TRX_UNDO_XA_BQUAL_LEN,
static_cast<ulint>(xid->bqual_length),
MLOG_4BYTES, mtr);
-
+ const ulint xid_length = static_cast<ulint>(xid->gtrid_length
+ + xid->bqual_length);
mlog_write_string(log_hdr + TRX_UNDO_XA_XID,
reinterpret_cast<const byte*>(xid->data),
- XIDDATASIZE, mtr);
+ xid_length, mtr);
+ mlog_memset(log_hdr + TRX_UNDO_XA_XID + xid_length,
+ XIDDATASIZE - xid_length, 0, mtr);
}
In trx_rseg_write_wsrep_checkpoint() there is a similar problem.
The function mlog_memset() (and the redo log record type MLOG_MEMSET) was introduced in MariaDB Server 10.4. In earlier versions, we will have to use mlog_write_string().
I suppose that the uninitialized data in buf_flush_try_neighbors() is the undo log block that is being flushed to the data file some time after the redo log. I did not see that failure after applying the above fix.