Bug #59178 Valgrind warnings rpl_get_master_version_and_clock
Submitted: 27 Dec 2010 5:34 Modified: 14 Mar 2011 5:47
Reporter: Zhenxing He Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1,5.5 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: pb2, valgrind

[27 Dec 2010 5:34] Zhenxing He
Description:
Valgrind rpl_get_master_version_and_clock.test starts fail with the following symptom after the patch for BUG#49978:

rpl.rpl_get_master_version_and_clock     w3 [ fail ]  Found warnings/errors in server log file!
        Test ended at 2010-12-24 13:21:23
line
==9150== Conditional jump or move depends on uninitialised value(s)
==9150==    at 0x4C21D66: strnlen (mc_replace_strmem.c:259)
==9150==    by 0xAC8D72: process_str_arg (my_vsnprintf.c:195)
==9150==    by 0xACAA70: my_vsnprintf_ex (my_vsnprintf.c:605)
==9150==    by 0xACAEB0: my_vsnprintf (my_vsnprintf.c:668)
==9150==    by 0xA938C6: DbugVfprintf (dbug.c:1350)
==9150==    by 0xA93869: _db_doprnt_ (dbug.c:1335)
==9150==    by 0x54AAF2: Protocol_text::store(char const*, unsigned long, charset_info_st*) (protocol.cc:986)
==9150==    by 0x748B50: Item::send(Protocol*, String*) (item.cc:5841)
==9150==    by 0x548CDC: Protocol::send_result_set_row(List<Item>*) (protocol.cc:848)
==9150==    by 0x5A8A88: select_send::send_data(List<Item>&) (sql_class.cc:1862)
==9150==    by 0x62C0EF: JOIN::exec() (sql_select.cc:1860)
==9150==    by 0x628CB2: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2571)
==9150==    by 0x62E414: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==9150==    by 0x5D5346: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4472)
==9150==    by 0x5D62AE: mysql_execute_command(THD*) (sql_parse.cc:2053)
==9150==    by 0x5DD2FE: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5509)
==9150== Conditional jump or move depends on uninitialised value(s)
==9150==    at 0xACB58F: strnmov (strnmov.c:29)
==9150==    by 0xAC8E03: process_str_arg (my_vsnprintf.c:203)
==9150==    by 0xACAA70: my_vsnprintf_ex (my_vsnprintf.c:605)
==9150==    by 0xACAEB0: my_vsnprintf (my_vsnprintf.c:668)
==9150==    by 0xA938C6: DbugVfprintf (dbug.c:1350)
==9150==    by 0xA93869: _db_doprnt_ (dbug.c:1335)
==9150==    by 0x54AAF2: Protocol_text::store(char const*, unsigned long, charset_info_st*) (protocol.cc:986)
==9150==    by 0x748B50: Item::send(Protocol*, String*) (item.cc:5841)
==9150==    by 0x548CDC: Protocol::send_result_set_row(List<Item>*) (protocol.cc:848)
==9150==    by 0x5A8A88: select_send::send_data(List<Item>&) (sql_class.cc:1862)
==9150==    by 0x62C0EF: JOIN::exec() (sql_select.cc:1860)
==9150==    by 0x628CB2: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2571)
==9150==    by 0x62E414: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==9150==    by 0x5D5346: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4472)
==9150==    by 0x5D62AE: mysql_execute_command(THD*) (sql_parse.cc:2053)
==9150==    by 0x5DD2FE: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5509)
==9150== Conditional jump or move depends on uninitialised value(s)
==9150==    at 0x4C21D98: strlen (mc_replace_strmem.c:275)
==9150==    by 0x594EB68: vfprintf (in /lib64/libc-2.5.so)
==9150==    by 0x594FF35: buffered_vfprintf (in /lib64/libc-2.5.so)
==9150==    by 0x594AA1B: vfprintf (in /lib64/libc-2.5.so)
==9150==    by 0x5955357: fprintf (in /lib64/libc-2.5.so)
==9150==    by 0xA938E5: DbugVfprintf (dbug.c:1351)
==9150==    by 0xA93869: _db_doprnt_ (dbug.c:1335)
==9150==    by 0x54AAF2: Protocol_text::store(char const*, unsigned long, charset_info_st*) (protocol.cc:986)
==9150==    by 0x748B50: Item::send(Protocol*, String*) (item.cc:5841)
==9150==    by 0x548CDC: Protocol::send_result_set_row(List<Item>*) (protocol.cc:848)
==9150==    by 0x5A8A88: select_send::send_data(List<Item>&) (sql_class.cc:1862)
==9150==    by 0x62C0EF: JOIN::exec() (sql_select.cc:1860)
==9150==    by 0x628CB2: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2571)
==9150==    by 0x62E414: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==9150==    by 0x5D5346: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4472)
==9150==    by 0x5D62AE: mysql_execute_command(THD*) (sql_parse.cc:2053)
==9150== Syscall param write(buf) points to uninitialised byte(s)
==9150==    at 0x59CE0AB: ??? (in /lib64/libc-2.5.so)
==9150==    by 0x5973AB2: _IO_file_write@@GLIBC_2.2.5 (in /lib64/libc-2.5.so)
==9150==    by 0x5974EF2: _IO_file_xsputn@@GLIBC_2.2.5 (in /lib64/libc-2.5.so)
==9150==    by 0x594FF91: buffered_vfprintf (in /lib64/libc-2.5.so)
==9150==    by 0x594AA1B: vfprintf (in /lib64/libc-2.5.so)
==9150==    by 0x5955357: fprintf (in /lib64/libc-2.5.so)
==9150==    by 0xA938E5: DbugVfprintf (dbug.c:1351)
==9150==    by 0xA93869: _db_doprnt_ (dbug.c:1335)
==9150==    by 0x54AAF2: Protocol_text::store(char const*, unsigned long, charset_info_st*) (protocol.cc:986)
==9150==    by 0x748B50: Item::send(Protocol*, String*) (item.cc:5841)
==9150==    by 0x548CDC: Protocol::send_result_set_row(List<Item>*) (protocol.cc:848)
==9150==    by 0x5A8A88: select_send::send_data(List<Item>&) (sql_class.cc:1862)
==9150==    by 0x62C0EF: JOIN::exec() (sql_select.cc:1860)
==9150==    by 0x628CB2: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2571)
==9150==    by 0x62E414: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==9150==    by 0x5D5346: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4472)
==9150==  Address 0x41b5515 is on thread 17's stack
^ Found warnings in /export/home2/pb2/test/sb_1-2712783-1293192975.36/mysql-5.5.9-linux-x86_64-test/mysql-test/var-n_mix/3/log/mysqld.2.err
ok

How to repeat:
This happens on mysql-5.1-bugteam and mysql-5.5-bugteam

http://pb2.norway.sun.com/?template=mysql_show_test_failure&search=yes&push_id=1858481&tes...

http://pb2.norway.sun.com/?template=mysql_show_test_failure&search=yes&push_id=1858225&tes...
[5 Jan 2011 13:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/127968

3534 Georgi Kodinov	2011-01-05
      Bug #59178: disable the test case
[5 Jan 2011 13:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/127970

3461 Georgi Kodinov	2011-01-05 [merge]
       Bug #59178 : null merge of the test disablement to trunk.
[5 Jan 2011 13:08] Bugs System
Pushed into mysql-5.1 5.1.55 (revid:georgi.kodinov@oracle.com-20110105125805-aedkj2j5lsx36m1u) (version source revid:georgi.kodinov@oracle.com-20110105125805-aedkj2j5lsx36m1u) (merge vers: 5.1.55) (pib:24)
[5 Jan 2011 13:08] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:georgi.kodinov@oracle.com-20110105130248-3vmoqbnt6mpc6xaj) (version source revid:georgi.kodinov@oracle.com-20110105130248-3vmoqbnt6mpc6xaj) (merge vers: 5.5.9) (pib:24)
[5 Jan 2011 13:09] Bugs System
Pushed into mysql-trunk 5.6.2 (revid:georgi.kodinov@oracle.com-20110105130642-p42be2bnf8h0zgag) (version source revid:georgi.kodinov@oracle.com-20110105130642-p42be2bnf8h0zgag) (merge vers: 5.6.2) (pib:24)
[5 Jan 2011 16:57] Alfranio Junior
Find in what follows how to repeat the problem:

./BUILD/compile-pentium64-valgrind-max

./mtr test.test --valgrind

== cat t/test.test ===
SELECT REPEAT(' ', 2);
[5 Jan 2011 17:13] Alfranio Junior
The valgrind errors stem from the sql/protocol.cc:859 where a non-null-terminated string is being printed out.

bool Protocol_text::store(const char *from, size_t length,
                          CHARSET_INFO *fromcs)
{
  CHARSET_INFO *tocs= this->thd->variables.character_set_results;
#ifndef DBUG_OFF
  DBUG_PRINT("info", ("Protocol_text::store field %u (%u): %s", field_pos,
                      field_count, (length == 0? "" : from)));
  DBUG_ASSERT(field_pos < field_count);
  DBUG_ASSERT(field_types == 0 ||
              field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
              field_types[field_pos] == MYSQL_TYPE_BIT ||
              field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL ||
              field_types[field_pos] == MYSQL_TYPE_NEWDATE || 
              (field_types[field_pos] >= MYSQL_TYPE_ENUM &&
               field_types[field_pos] <= MYSQL_TYPE_GEOMETRY));
  field_pos++; 
#endif
  return store_string_aux(from, length, fromcs, tocs);
} 

I don't know if at this point all strings should be null-terminated.
[12 Mar 2011 12:15] Andrei Elkin
Ramil, this bug must have been addressed by a bug#59060 patch.
The stacks are identical, so I would suggest a duplicate.

I run into these two while hunting over Bug #58754.
[14 Mar 2011 5:47] Ramil Kalimullin
Closing as a duplicate, see Andrei's comment.