Bug #53202 valgrind: uninitialized bytes in dtuple_print()
Submitted: 27 Apr 2010 13:58 Modified: 19 Jun 2010 18:00
Reporter: Vasil Dimov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:mysql-5.1 OS:Any
Assigned to: Marko Mäkelä CPU Architecture:Any

[27 Apr 2010 13:58] Vasil Dimov
Description:
==14568== Thread 11:
==14568== Uninitialised byte(s) found during client check request
==14568==    at 0x8EFF2D: ut_print_buf (ut0ut.c:375)
==14568==    by 0x85972D: dtuple_print (data0data.c:448)
==14568==    by 0x8B6D84: row_ins_foreign_report_add_err (row0ins.c:696)
==14568==    by 0x8B77C7: row_ins_check_foreign_constraint (row0ins.c:1448)
==14568==    by 0x8B7BF7: row_ins_index_entry (row0ins.c:1542)
==14568==    by 0x8B7EEA: row_ins (row0ins.c:2259)
==14568==    by 0x8B826A: row_ins_step (row0ins.c:2501)
==14568==    by 0x8BA667: row_insert_for_mysql (row0mysql.c:1161)
==14568==    by 0x838C6D: ha_innobase::write_row(unsigned char*) 

dscczz02:~/mysql-5.1-innodb$ grep '\$ \./configure' config.log 
  $ ./configure --enable-thread-safe-client --enable-local-infile --with-pic --with-client-ldflags=-static --with-mysqld-ldflags=-static --with-zlib-dir=bundled --without-ndb-debug --with-big-tables --with-ssl --with-readline --with-embedded-server --with-archive-storage-engine --with-blackhole-storage-engine --with-csv-storage-engine --with-example-storage-engine --with-federated-storage-engine --with-partition --with-extra-charsets=all --with-innodb --with-ndbcluster --with-debug --prefix=/home/vdimov/mysql-5.1-innodb-install
dscczz02:~/mysql-5.1-innodb$ 

How to repeat:
Logging: ./mtr  --valgrind --valgrind-option=--gen-suppressions=all --valgrind-option=--show-reachable=yes innodb.innodb_misc1
...
TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
innodb.innodb_misc1                      [ fail ]  Found warnings/errors in server log file!
        Test ended at 2010-04-27 06:50:57
line
==14568== Thread 11:
==14568== Uninitialised byte(s) found during client check request
==14568==    at 0x8EFF2D: ut_print_buf (ut0ut.c:375)
==14568==    by 0x85972D: dtuple_print (data0data.c:448)
==14568==    by 0x8B6D84: row_ins_foreign_report_add_err (row0ins.c:696)
==14568==    by 0x8B77C7: row_ins_check_foreign_constraint (row0ins.c:1448)
==14568==    by 0x8B7BF7: row_ins_index_entry (row0ins.c:1542)
==14568==    by 0x8B7EEA: row_ins (row0ins.c:2259)
==14568==    by 0x8B826A: row_ins_step (row0ins.c:2501)
==14568==    by 0x8BA667: row_insert_for_mysql (row0mysql.c:1161)
==14568==    by 0x838C6D: ha_innobase::write_row(unsigned char*) (ha_innodb.cc:4013)
==14568==    by 0x73455E: handler::ha_write_row(unsigned char*) (handler.cc:4650)
==14568==    by 0x6B460C: write_record(THD*, st_table*, st_copy_info*) (sql_insert.cc:1606)
==14568==    by 0x6B93C6: mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) (sql_insert.cc:835)
==14568==    by 0x638335: mysql_execute_command(THD*) (sql_parse.cc:3183)
==14568==    by 0x63C203: mysql_parse(THD*, char const*, unsigned, char const**) (sql_parse.cc:5971)
==14568==    by 0x63CCC5: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1233)
==14568==    by 0x63E0C9: do_command(THD*) (sql_parse.cc:874)
==14568==  Address 0x5A4ACE8 is 138,424 bytes inside a block of size 1,048,608 alloc'd
==14568==    at 0x4A05809: malloc (vg_replace_malloc.c:149)
==14568==    by 0x8EF5D9: ut_malloc_low (ut0mem.c:82)
==14568==    by 0x89B2E3: mem_pool_create (mem0pool.c:203)
==14568==    by 0x89AAD8: mem_init (mem0dbg.c:136)
==14568==    by 0x8D1DF9: srv_general_init (srv0srv.c:985)
==14568==    by 0x8D2797: srv_boot (srv0srv.c:1327)
==14568==    by 0x8D5886: innobase_start_or_create_for_mysql (srv0start.c:1198)
==14568==    by 0x835DB8: innobase_init(void*) (ha_innodb.cc:1971)
==14568==    by 0x731C4E: ha_initialize_handlerton(st_plugin_int*) (handler.cc:435)
==14568==    by 0x7D471C: plugin_initialize(st_plugin_int*) (sql_plugin.cc:1014)
==14568==    by 0x7D78BD: plugin_init(int*, char**, int) (sql_plugin.cc:1238)
==14568==    by 0x624B23: init_server_components() (mysqld.cc:3950)
==14568==    by 0x629374: main (mysqld.cc:4421)
==14568== (Memcheck does not allow error to be suppressed)
==14568== Use of uninitialised value of size 8
==14568==    at 0x3C1A2419E1: _itoa_word (in /lib64/libc-2.5.so)
==14568==    by 0x3C1A244E5A: vfprintf (in /lib64/libc-2.5.so)
==14568==    by 0x3C1A24D357: fprintf (in /lib64/libc-2.5.so)
==14568==    by 0x8EFF77: ut_print_buf (ut0ut.c:380)
==14568==    by 0x85972D: dtuple_print (data0data.c:448)
==14568==    by 0x8B6D84: row_ins_foreign_report_add_err (row0ins.c:696)
==14568==    by 0x8B77C7: row_ins_check_foreign_constraint (row0ins.c:1448)
==14568==    by 0x8B7BF7: row_ins_index_entry (row0ins.c:1542)
==14568==    by 0x8B7EEA: row_ins (row0ins.c:2259)
==14568==    by 0x8B826A: row_ins_step (row0ins.c:2501)
==14568==    by 0x8BA667: row_insert_for_mysql (row0mysql.c:1161)
==14568==    by 0x838C6D: ha_innobase::write_row(unsigned char*) (ha_innodb.cc:4013)
==14568==    by 0x73455E: handler::ha_write_row(unsigned char*) (handler.cc:4650)
==14568==    by 0x6B460C: write_record(THD*, st_table*, st_copy_info*) (sql_insert.cc:1606)
==14568==    by 0x6B93C6: mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) (sql_insert.cc:835)
==14568==    by 0x638335: mysql_execute_command(THD*) (sql_parse.cc:3183)
==14568== Conditional jump or move depends on uninitialised value(s)
==14568==    at 0x3C1A2419E8: _itoa_word (in /lib64/libc-2.5.so)
==14568==    by 0x3C1A244E5A: vfprintf (in /lib64/libc-2.5.so)
==14568==    by 0x3C1A24D357: fprintf (in /lib64/libc-2.5.so)
==14568==    by 0x8EFF77: ut_print_buf (ut0ut.c:380)
==14568==    by 0x85972D: dtuple_print (data0data.c:448)
==14568==    by 0x8B6D84: row_ins_foreign_report_add_err (row0ins.c:696)
==14568==    by 0x8B77C7: row_ins_check_foreign_constraint (row0ins.c:1448)
==14568==    by 0x8B7BF7: row_ins_index_entry (row0ins.c:1542)
==14568==    by 0x8B7EEA: row_ins (row0ins.c:2259)
==14568==    by 0x8B826A: row_ins_step (row0ins.c:2501)
==14568==    by 0x8BA667: row_insert_for_mysql (row0mysql.c:1161)
==14568==    by 0x838C6D: ha_innobase::write_row(unsigned char*) (ha_innodb.cc:4013)
==14568==    by 0x73455E: handler::ha_write_row(unsigned char*) (handler.cc:4650)
==14568==    by 0x6B460C: write_record(THD*, st_table*, st_copy_info*) (sql_insert.cc:1606)
==14568==    by 0x6B93C6: mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) (sql_insert.cc:835)
==14568==    by 0x638335: mysql_execute_command(THD*) (sql_parse.cc:3183)
==14568== Conditional jump or move depends on uninitialised value(s)
==14568==    at 0x3C1A244ED4: vfprintf (in /lib64/libc-2.5.so)
==14568==    by 0x3C1A24D357: fprintf (in /lib64/libc-2.5.so)
==14568==    by 0x8EFF77: ut_print_buf (ut0ut.c:380)
==14568==    by 0x85972D: dtuple_print (data0data.c:448)
==14568==    by 0x8B6D84: row_ins_foreign_report_add_err (row0ins.c:696)
==14568==    by 0x8B77C7: row_ins_check_foreign_constraint (row0ins.c:1448)
==14568==    by 0x8B7BF7: row_ins_index_entry (row0ins.c:1542)
==14568==    by 0x8B7EEA: row_ins (row0ins.c:2259)
==14568==    by 0x8B826A: row_ins_step (row0ins.c:2501)
==14568==    by 0x8BA667: row_insert_for_mysql (row0mysql.c:1161)
==14568==    by 0x838C6D: ha_innobase::write_row(unsigned char*) (ha_innodb.cc:4013)
==14568==    by 0x73455E: handler::ha_write_row(unsigned char*) (handler.cc:4650)
==14568==    by 0x6B460C: write_record(THD*, st_table*, st_copy_info*) (sql_insert.cc:1606)
==14568==    by 0x6B93C6: mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) (sql_insert.cc:835)
==14568==    by 0x638335: mysql_execute_command(THD*) (sql_parse.cc:3183)
==14568==    by 0x63C203: mysql_parse(THD*, char const*, unsigned, char const**) (sql_parse.cc:5971)
==14568== Use of uninitialised value of size 8
==14568==    at 0x8EFFAF: ut_print_buf (ut0ut.c:389)
==14568==    by 0x85972D: dtuple_print (data0data.c:448)
==14568==    by 0x8B6D84: row_ins_foreign_report_add_err (row0ins.c:696)
==14568==    by 0x8B77C7: row_ins_check_foreign_constraint (row0ins.c:1448)
==14568==    by 0x8B7BF7: row_ins_index_entry (row0ins.c:1542)
==14568==    by 0x8B7EEA: row_ins (row0ins.c:2259)
==14568==    by 0x8B826A: row_ins_step (row0ins.c:2501)
==14568==    by 0x8BA667: row_insert_for_mysql (row0mysql.c:1161)
==14568==    by 0x838C6D: ha_innobase::write_row(unsigned char*) (ha_innodb.cc:4013)
==14568==    by 0x73455E: handler::ha_write_row(unsigned char*) (handler.cc:4650)
==14568==    by 0x6B460C: write_record(THD*, st_table*, st_copy_info*) (sql_insert.cc:1606)
==14568==    by 0x6B93C6: mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) (sql_insert.cc:835)
==14568==    by 0x638335: mysql_execute_command(THD*) (sql_parse.cc:3183)
==14568==    by 0x63C203: mysql_parse(THD*, char const*, unsigned, char const**) (sql_parse.cc:5971)
==14568==    by 0x63CCC5: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1233)
==14568==    by 0x63E0C9: do_command(THD*) (sql_parse.cc:874)
^ Found warnings in /home/vdimov/mysql-5.1-innodb/mysql-test/var/log/mysqld.1.err

Suggested fix:
Compile mysqld with the above ./configure line and run the test as shown above.

This is revealed by storage/innobase/include/univ.i:

#ifdef HAVE_purify
# define UNIV_DEBUG_VALGRIND
#endif /* HAVE_purify */

you must have purify or define UNIV_DEBUG_VALGRIND manually in order to reproduce this.
[28 Apr 2010 6:37] Marko Mäkelä
Fixed in mysql-5.1-innodb r3426 by merging r6103 from the InnoDB Plugin (2009-10-26). When reporting a foreign key constraint violation during INSERT, InnoDB could display uninitialized data for the system columns DB_TRX_ID and DB_ROLL_PTR. These columns would be initialized when inserting the record into the clustered index B-tree.
[5 May 2010 15:11] Bugs System
Pushed into 5.1.47 (revid:joro@sun.com-20100505145753-ivlt4hclbrjy8eye) (version source revid:kristofer.pettersson@sun.com-20100503172109-f9hracq5pqsaomb1) (merge vers: 5.1.47) (pib:16)
[13 May 2010 0:18] Paul DuBois
Noted in 5.1.47 changelog.

When reporting a foreign key constraint violation during INSERT,
InnoDB could display uninitialized data for the DB_TRX_ID and
DB_ROLL_PTR system columns.
[28 May 2010 6:11] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100524190136-egaq7e8zgkwb9aqi) (version source revid:alik@sun.com-20100512070920-xgpmqeytp0gc183c) (pib:16)
[28 May 2010 6:39] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100524190941-nuudpx60if25wsvx) (version source revid:alik@sun.com-20100507093037-7cykrx1n73v0tetc) (merge vers: 6.0.14-alpha) (pib:16)
[28 May 2010 7:06] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100524185725-c8k5q7v60i5nix3t) (version source revid:alexey.kopytov@sun.com-20100507164602-8w09samq3mpvbxbn) (merge vers: 5.5.5-m3) (pib:16)
[29 May 2010 22:45] Paul DuBois
Noted in 5.5.5, 6.0.14 changelogs.
[17 Jun 2010 12:16] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:martin.skold@mysql.com-20100616204905-jxjg342w35ks9vfy) (merge vers: 5.1.47-ndb-7.0.16) (pib:16)
[17 Jun 2010 13:03] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:martin.skold@mysql.com-20100615090726-jotpykke96le59w5) (merge vers: 5.1.47-ndb-6.2.19) (pib:16)
[17 Jun 2010 13:43] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:martin.skold@mysql.com-20100616120453-jh7wr05z1vf7r8pm) (merge vers: 5.1.47-ndb-6.3.35) (pib:16)