Bug #61550 Valgrind warnings on various MTR tests with MyISAM tables 5.5 bzr rev. 3462
Submitted: 17 Jun 2011 11:12 Modified: 21 Oct 2011 7:05
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:5.5 OS:Linux (Ubuntu 10.10 x86_64)
Assigned to: CPU Architecture:Any

[17 Jun 2011 11:12] Laurynas Biveinis
Description:
perfschema.selects                       [ fail ]  Found warnings/errors in server log file!
        Test ended at 2011-06-17 14:09:14
line
==2662== Thread 14:
==2662== Syscall param write(buf) points to uninitialised byte(s)
==2662==    at 0x4E3CB2D: ??? (syscall-template.S:82)
==2662==    by 0x8EB6D3: my_write (my_write.c:41)
==2662==    by 0x8C540E: inline_mysql_file_write (mysql_file.h:1134)
==2662==    by 0x8C83C1: my_b_flush_io_cache (mf_iocache.c:1775)
==2662==    by 0x747DFA: merge_many_buff(st_sort_param*, unsigned char*, st_buffpek*, unsigned int*, st_io_cache*) (filesort.cc:1081)
==2662==    by 0x745B11: filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*) (filesort.cc:290)
==2662==    by 0x623CAC: create_sort_index(THD*, JOIN*, st_order*, unsigned long long, unsigned long long, bool) (sql_select.cc:14126)
==2662==    by 0x6069E1: JOIN::exec() (sql_select.cc:2334)
==2662==    by 0x607393: 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:2579)
==2662==    by 0x5FF580: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==2662==    by 0x5D8E2F: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4511)
==2662==    by 0x5D1791: mysql_execute_command(THD*) (sql_parse.cc:2118)
==2662==    by 0x5DB119: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==2662==    by 0x5CEC90: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==2662==    by 0x5CDE6A: do_command(THD*) (sql_parse.cc:771)
==2662==    by 0x6BBFC5: do_handle_one_connection(THD*) (sql_connect.cc:787)
==2662==  Address 0xf308bbc is 76 bytes inside a block of size 65,536 alloc'd
==2662==    at 0x4C2815C: malloc (vg_replace_malloc.c:236)
==2662==    by 0x8E4D17: my_malloc (my_malloc.c:38)
==2662==    by 0x8C5C45: init_io_cache (mf_iocache.c:232)
==2662==    by 0x8C33D6: open_cached_file (mf_cache.c:69)
==2662==    by 0x74704D: write_keys(st_sort_param*, unsigned char**, unsigned int, st_io_cache*, st_io_cache*) (filesort.cc:709)
==2662==    by 0x746CFD: find_all_keys(st_sort_param*, SQL_SELECT*, unsigned char**, st_io_cache*, st_io_cache*, st_io_cache*) (filesort.cc:630)
==2662==    by 0x7458C4: filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*) (filesort.cc:250)
==2662==    by 0x623CAC: create_sort_index(THD*, JOIN*, st_order*, unsigned long long, unsigned long long, bool) (sql_select.cc:14126)
==2662==    by 0x6069E1: JOIN::exec() (sql_select.cc:2334)
==2662==    by 0x607393: 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:2579)
==2662==    by 0x5FF580: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==2662==    by 0x5D8E2F: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4511)
==2662==    by 0x5D1791: mysql_execute_command(THD*) (sql_parse.cc:2118)
==2662==    by 0x5DB119: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==2662==    by 0x5CEC90: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==2662==    by 0x5CDE6A: do_command(THD*) (sql_parse.cc:771)

How to repeat:
cmake options: -DWITH_DEBUG=ON -DWITH_VALGRIND=ON

./mysql-test-run.pl --valgrind-mysqld perfschema.selects
[17 Jun 2011 11:12] Laurynas Biveinis
Full output

Attachment: valgrind.log (text/x-log), 6.17 KiB.

[17 Jun 2011 12:43] Laurynas Biveinis
Provide system info
[17 Jun 2011 12:54] Laurynas Biveinis
There is a warning with the same stack trace on perfschema.dml_ews_by_instance too.
[17 Jun 2011 13:11] Laurynas Biveinis
Another failing test, with the same backtrace up to _my_b_write:

main.ctype_cp932_binlog_stm              [ fail ]  Found warnings/errors in server log file!
        Test ended at 2011-06-17 16:07:06
line
==4098== Thread 13:
==4098== Syscall param write(buf) points to uninitialised byte(s)
==4098==    at 0x4E3CB2D: ??? (syscall-template.S:82)
==4098==    by 0x8EB6D3: my_write (my_write.c:41)
==4098==    by 0x8C540E: inline_mysql_file_write (mysql_file.h:1134)
==4098==    by 0x8C83C1: my_b_flush_io_cache (mf_iocache.c:1775)
==4098==    by 0x8C7B63: _my_b_write (mf_iocache.c:1544)
==4098==    by 0x7471B9: write_keys(st_sort_param*, unsigned char**, unsigned int, st_io_cache*, st_io_cache*) (filesort.cc:721)
==4098==    by 0x746CFD: find_all_keys(st_sort_param*, SQL_SELECT*, unsigned char**, st_io_cache*, st_io_cache*, st_io_cache*) (filesort.cc:630)
==4098==    by 0x7458C4: filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*) (filesort.cc:250)
==4098==    by 0x623CAC: create_sort_index(THD*, JOIN*, st_order*, unsigned long long, unsigned long long, bool) (sql_select.cc:14126)
==4098==    by 0x6069E1: JOIN::exec() (sql_select.cc:2334)
==4098==    by 0x607393: 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:2579)
==4098==    by 0x5FF580: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==4098==    by 0x5D8E2F: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4511)
==4098==    by 0x5D1791: mysql_execute_command(THD*) (sql_parse.cc:2118)
==4098==    by 0x5DB119: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==4098==    by 0x5CEC90: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==4098==  Address 0x7abef2f is 15 bytes inside a block of size 65,536 alloc'd
==4098==    at 0x4C2815C: malloc (vg_replace_malloc.c:236)
==4098==    by 0x8E4D17: my_malloc (my_malloc.c:38)
==4098==    by 0x8C5C45: init_io_cache (mf_iocache.c:232)
==4098==    by 0x8C33D6: open_cached_file (mf_cache.c:69)
==4098==    by 0x74704D: write_keys(st_sort_param*, unsigned char**, unsigned int, st_io_cache*, st_io_cache*) (filesort.cc:709)
==4098==    by 0x746CFD: find_all_keys(st_sort_param*, SQL_SELECT*, unsigned char**, st_io_cache*, st_io_cache*, st_io_cache*) (filesort.cc:630)
==4098==    by 0x7458C4: filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*) (filesort.cc:250)
==4098==    by 0x623CAC: create_sort_index(THD*, JOIN*, st_order*, unsigned long long, unsigned long long, bool) (sql_select.cc:14126)
==4098==    by 0x6069E1: JOIN::exec() (sql_select.cc:2334)
==4098==    by 0x607393: 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:2579)
==4098==    by 0x5FF580: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==4098==    by 0x5D8E2F: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4511)
==4098==    by 0x5D1791: mysql_execute_command(THD*) (sql_parse.cc:2118)
==4098==    by 0x5DB119: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==4098==    by 0x5CEC90: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==4098==    by 0x5CDE6A: do_command(THD*) (sql_parse.cc:771)
[17 Jun 2011 13:24] Laurynas Biveinis
And another failing test:

main.index_merge_myisam                  [ fail ]  Found warnings/errors in server log file!
        Test ended at 2011-06-17 16:22:56
line
==4230== Thread 14:
==4230== Syscall param write(buf) points to uninitialised byte(s)
==4230==    at 0x4E3CB2D: ??? (syscall-template.S:82)
==4230==    by 0x8EB6D3: my_write (my_write.c:41)
==4230==    by 0x8C540E: inline_mysql_file_write (mysql_file.h:1134)
==4230==    by 0x8C83C1: my_b_flush_io_cache (mf_iocache.c:1775)
==4230==    by 0x745B32: filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*) (filesort.cc:293)
==4230==    by 0x623CAC: create_sort_index(THD*, JOIN*, st_order*, unsigned long long, unsigned long long, bool) (sql_select.cc:14126)
==4230==    by 0x6069E1: JOIN::exec() (sql_select.cc:2334)
==4230==    by 0x607393: 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:2579)
==4230==    by 0x5FF580: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==4230==    by 0x5D8E2F: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4511)
==4230==    by 0x5D1791: mysql_execute_command(THD*) (sql_parse.cc:2118)
==4230==    by 0x5DB119: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==4230==    by 0x5CEC90: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==4230==    by 0x5CDE6A: do_command(THD*) (sql_parse.cc:771)
==4230==    by 0x6BBFC5: do_handle_one_connection(THD*) (sql_connect.cc:787)
==4230==    by 0x6BBA80: handle_one_connection (sql_connect.cc:706)
==4230==  Address 0xc9a6254 is 388 bytes inside a block of size 65,536 alloc'd
==4230==    at 0x4C2815C: malloc (vg_replace_malloc.c:236)
==4230==    by 0x8E4D17: my_malloc (my_malloc.c:38)
==4230==    by 0x8C5C45: init_io_cache (mf_iocache.c:232)
==4230==    by 0x8C33D6: open_cached_file (mf_cache.c:69)
==4230==    by 0x74704D: write_keys(st_sort_param*, unsigned char**, unsigned int, st_io_cache*, st_io_cache*) (filesort.cc:709)
==4230==    by 0x746CFD: find_all_keys(st_sort_param*, SQL_SELECT*, unsigned char**, st_io_cache*, st_io_cache*, st_io_cache*) (filesort.cc:630)
==4230==    by 0x7458C4: filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*) (filesort.cc:250)
==4230==    by 0x623CAC: create_sort_index(THD*, JOIN*, st_order*, unsigned long long, unsigned long long, bool) (sql_select.cc:14126)
==4230==    by 0x6069E1: JOIN::exec() (sql_select.cc:2334)
==4230==    by 0x607393: 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:2579)
==4230==    by 0x5FF580: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==4230==    by 0x5D8E2F: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4511)
==4230==    by 0x5D1791: mysql_execute_command(THD*) (sql_parse.cc:2118)
==4230==    by 0x5DB119: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==4230==    by 0x5CEC90: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==4230==    by 0x5CDE6A: do_command(THD*) (sql_parse.cc:771)
==4230== Conditional jump or move depends on uninitialised value(s)
==4230==    at 0x5256E40: inflateReset2 (in /lib/libz.so.1.2.3.4)
==4230==    by 0x5256F2F: inflateInit2_ (in /lib/libz.so.1.2.3.4)
==4230==    by 0x5251648: uncompress (in /lib/libz.so.1.2.3.4)
==4230==    by 0x7CE5D5: Item_func_uncompress::val_str(String*) (item_strfunc.cc:3711)
==4230==    by 0x7B04D7: Item_func_set_user_var::check(bool) (item_func.cc:4556)
==4230==    by 0x545638: set_var_user::check(THD*) (set_var.cc:689)
==4230==    by 0x54511B: sql_set_variables(THD*, List<set_var_base>*) (set_var.cc:571)
==4230==    by 0x5D464B: mysql_execute_command(THD*) (sql_parse.cc:3105)
==4230==    by 0x5DB119: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==4230==    by 0x5CEC90: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==4230==    by 0x5CDE6A: do_command(THD*) (sql_parse.cc:771)
==4230==    by 0x6BBFC5: do_handle_one_connection(THD*) (sql_connect.cc:787)
==4230==    by 0x6BBA80: handle_one_connection (sql_connect.cc:706)
==4230==    by 0x90D840: pfs_spawn_thread (pfs.cc:1015)
==4230==    by 0x4E35970: start_thread (pthread_create.c:304)
==4230==    by 0x636192C: clone (clone.S:112)
[17 Jun 2011 13:54] MySQL Verification Team
Thank you for the bug report.

miguel@lempa:~/bzr/5.5/mysql-test$ ./mysql-test-run.pl --valgrind-mysqld perfschema.selects
Logging: ./mysql-test-run.pl  --valgrind-mysqld perfschema.selects
MySQL Version 5.5.15
Turning on valgrind for mysqld(s) only
Running valgrind with options " --show-reachable=yes "
Checking supported features...
 - skipping ndbcluster
 - skipping SSL, mysqld not compiled with SSL
 - binaries are debug compiled
Collecting tests...
vardir: /home/miguel/bzr/5.5/mysql-test/var
Removing old var directory...
Creating var directory '/home/miguel/bzr/5.5/mysql-test/var'...
Installing system database...
Using server port 45507

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
perfschema.selects                       [ fail ]  Found warnings/errors in server log file!
        Test ended at 2011-06-17 10:53:17
line
==16218== Thread 14:
==16218== Syscall param write(buf) points to uninitialised byte(s)
==16218==    at 0x4E3DC5D: ??? (syscall-template.S:82)
==16218==    by 0x8C5F4D: my_write (my_write.c:41)
==16218==    by 0x8A0FA9: inline_mysql_file_write (mysql_file.h:1134)
==16218==    by 0x8A3E9E: my_b_flush_io_cache (mf_iocache.c:1775)
==16218==    by 0x7451EA: filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*) (filesort.cc:293)
==16218==    by 0x633B03: create_sort_index(THD*, JOIN*, st_order*, unsigned long long, unsigned long long, bool) (sql_select.cc:14126)
==16218==    by 0x6170EA: JOIN::exec() (sql_select.cc:2340)
==16218==    by 0x617A71: 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:2579)
==16218==    by 0x60FE50: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==16218==    by 0x5EC0BA: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4511)
==16218==    by 0x5E4F62: mysql_execute_command(THD*) (sql_parse.cc:2118)
==16218==    by 0x5EE176: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==16218==    by 0x5E270C: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==16218==    by 0x5E1A62: do_command(THD*) (sql_parse.cc:771)
==16218==    by 0x6C3D0D: do_handle_one_connection(THD*) (sql_connect.cc:787)
==16218==    by 0x6C383A: handle_one_connection (sql_connect.cc:706)
==16218==  Address 0xeeaa03b is 75 bytes inside a block of size 65,536 alloc'd
==16218==    at 0x4C28FAC: malloc (vg_replace_malloc.c:236)
==16218==    by 0x8BF939: my_malloc (my_malloc.c:38)
==16218==    by 0x8A1754: init_io_cache (mf_iocache.c:232)
==16218==    by 0x89F0E4: open_cached_file (mf_cache.c:69)
==16218==    by 0x746669: write_keys(st_sort_param*, unsigned char**, unsigned int, st_io_cache*, st_io_cache*) (filesort.cc:711)
==16218==    by 0x74632A: find_all_keys(st_sort_param*, SQL_SELECT*, unsigned char**, st_io_cache*, st_io_cache*, st_io_cache*) (filesort.cc:630)
==16218==    by 0x744F8B: filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*) (filesort.cc:250)
==16218==    by 0x633B03: create_sort_index(THD*, JOIN*, st_order*, unsigned long long, unsigned long long, bool) (sql_select.cc:14126)
==16218==    by 0x6170EA: JOIN::exec() (sql_select.cc:2340)
==16218==    by 0x617A71: 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:2579)
==16218==    by 0x60FE50: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:297)
==16218==    by 0x5EC0BA: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4511)
==16218==    by 0x5E4F62: mysql_execute_command(THD*) (sql_parse.cc:2118)
==16218==    by 0x5EE176: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5548)
==16218==    by 0x5E270C: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1034)
==16218==    by 0x5E1A62: do_command(THD*) (sql_parse.cc:771)
^ Found warnings in /home/miguel/bzr/5.5/mysql-test/var/log/mysqld.1.err
ok

 - saving '/home/miguel/bzr/5.5/mysql-test/var/log/perfschema.selects/' to '/home/miguel/bzr/5.5/mysql-test/var/log/perfschema.selects/'
worker[1] Valgrind report from /home/miguel/bzr/5.5/mysql-test/var/log/mysqld.1.err after tests:
 perfschema.selects
--------------------------------------------------------------------------
HEAP SUMMARY:
    in use at exit: 30,570,208 bytes in 208 blocks
  total heap usage: 71,916 allocs, 71,708 frees, 90,729,396 bytes allocated

LEAK SUMMARY:
   definitely lost: 0 bytes in 0 blocks
   indirectly lost: 0 bytes in 0 blocks
     possibly lost: 0 bytes in 0 blocks
   still reachable: 0 bytes in 0 blocks
        suppressed: 30,570,208 bytes in 208 blocks

For counts of detected and suppressed errors, rerun with: -v
Use --track-origins=yes to see where uninitialised values come from
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 76 from 76)

valgrind_report                          [ fail ]
        Test ended at 2011-06-17 10:53:17

Valgrind reported failures at shutdown, see above
[21 Oct 2011 7:02] Tor Didriksen
The most recent version of 5.5 has suppressions for these warnings
(which are benign: parts of the filesort buffer is unused,
but we're writing the whole thing to disk)

There are three suppress patterns, the first one looks like this:

# Note the wildcard in the (mangled) function signatures of
# write_keys() and find_all_keys().
# They both return ha_rows, which is platform dependent.
#
# The '...' wildcards are for 'fun:inline_mysql_file_write' which *may*
# be inlined.
{
   Bug#12856915 VALGRIND FAILURE IN FILESORT/CREATE_SORT_INDEX / one
   Memcheck:Param
   write(buf)
   obj:*/libpthread*.so
   fun:my_write
   ...
   fun:my_b_flush_io_cache
   fun:_my_b_write
   fun:_Z*10write_keysP13st_sort_paramPPhjP11st_io_cacheS4_
   fun:_Z*13find_all_keysP13st_sort_paramP10SQL_SELECTPPhP11st_io_cacheS6_S6_
   fun:_Z8filesortP3THDP5TABLEP13st_sort_fieldjP10SQL_SELECTybPy
}