Bug #38023 valgrind warns inside SELECT code
Submitted: 10 Jul 2008 16:03 Modified: 16 Dec 2008 18:29
Reporter: Rafal Somla Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:mysql-6.0 OS:Any
Assigned to: Alexander Nozdrin CPU Architecture:Any
Triage: Triaged: D2 (Serious)

[10 Jul 2008 16:03] Rafal Somla
Description:
When executing these statements

SET SESSION debug="d,";
SELECT dl FROM mysql.plugin WHERE name='foo';

valgrind reports the following:

==1672== Use of uninitialised value of size 4
==1672==    at 0x4203519: _itoa_word (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x42076EA: vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x4203D12: buffered_vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x420490E: vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x420D2E1: fprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x83A8EA9: print_keyuse(keyuse_t*) (sql_test.cc:244)
==1672==    by 0x83A8F18: print_keyuse_array(st_dynamic_array*) (sql_test.cc:256)
==1672==    by 0x8374CAB: update_ref_and_keys(THD*, st_dynamic_array*, st_join_table*, unsigned, Item*, COND_EQUAL*, unsigned long long, st_select_lex*, st_sargable_par
am**) (sql_select.cc:5201)
==1672==    by 0x8378F34: make_join_statistics(JOIN*, TABLE_LIST*, Item*, st_dynamic_array*) (sql_select.cc:3943)
==1672==    by 0x837CA2F: JOIN::optimize() (sql_select.cc:1549)
==1672==    by 0x8380516: mysql_select(THD*, Item***, TABLE_LIST*, unsigned, List<Item>&, Item*, unsigned, st_order*, st_order*, Item*, st_order*, unsigned long long, s
elect_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2987)
==1672==    by 0x8385503: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:302)
==1672==    by 0x82FBDA6: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4847)
==1672==    by 0x82FD5BD: mysql_execute_command(THD*) (sql_parse.cc:2015)
==1672==    by 0x830657E: mysql_parse(THD*, char const*, unsigned, char const**) (sql_parse.cc:5811)
==1672==    by 0x8306FED: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1051)
==1672== 

==1672== Conditional jump or move depends on uninitialised value(s)
==1672==    at 0x4203521: _itoa_word (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x42076EA: vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x4203D12: buffered_vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x420490E: vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x420D2E1: fprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x83A8EA9: print_keyuse(keyuse_t*) (sql_test.cc:244)
==1672==    by 0x83A8F18: print_keyuse_array(st_dynamic_array*) (sql_test.cc:256)
==1672==    by 0x8374CAB: update_ref_and_keys(THD*, st_dynamic_array*, st_join_table*, unsigned, Item*, COND_EQUAL*, unsigned long long, st_select_lex*, st_sargable_par
am**) (sql_select.cc:5201)
==1672==    by 0x8378F34: make_join_statistics(JOIN*, TABLE_LIST*, Item*, st_dynamic_array*) (sql_select.cc:3943)
==1672==    by 0x837CA2F: JOIN::optimize() (sql_select.cc:1549)
==1672==    by 0x8380516: mysql_select(THD*, Item***, TABLE_LIST*, unsigned, List<Item>&, Item*, unsigned, st_order*, st_order*, Item*, st_order*, unsigned long long, s
elect_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2987)
==1672==    by 0x8385503: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:302)
==1672==    by 0x82FBDA6: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4847)
==1672==    by 0x82FD5BD: mysql_execute_command(THD*) (sql_parse.cc:2015)
==1672==    by 0x830657E: mysql_parse(THD*, char const*, unsigned, char const**) (sql_parse.cc:5811)
==1672==    by 0x8306FED: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1051)
==1672== 

==1672== Conditional jump or move depends on uninitialised value(s)
==1672==    at 0x4205116: vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x4203D12: buffered_vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x420490E: vfprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x420D2E1: fprintf (in /lib/tls/libc-2.3.6.so)
==1672==    by 0x83A8EA9: print_keyuse(keyuse_t*) (sql_test.cc:244)
==1672==    by 0x83A8F18: print_keyuse_array(st_dynamic_array*) (sql_test.cc:256)
==1672==    by 0x8374CAB: update_ref_and_keys(THD*, st_dynamic_array*, st_join_table*, unsigned, Item*, COND_EQUAL*, unsigned long long, st_select_lex*, st_sargable_par
am**) (sql_select.cc:5201)
==1672==    by 0x8378F34: make_join_statistics(JOIN*, TABLE_LIST*, Item*, st_dynamic_array*) (sql_select.cc:3943)
==1672==    by 0x837CA2F: JOIN::optimize() (sql_select.cc:1549)
==1672==    by 0x8380516: mysql_select(THD*, Item***, TABLE_LIST*, unsigned, List<Item>&, Item*, unsigned, st_order*, st_order*, Item*, st_order*, unsigned long long, s
elect_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2987)
==1672==    by 0x8385503: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:302)
==1672==    by 0x82FBDA6: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4847)
==1672==    by 0x82FD5BD: mysql_execute_command(THD*) (sql_parse.cc:2015)
==1672==    by 0x830657E: mysql_parse(THD*, char const*, unsigned, char const**) (sql_parse.cc:5811)
==1672==    by 0x8306FED: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1051)
==1672==    by 0x83082B3: do_command(THD*) (sql_parse.cc:724)

How to repeat:
Create test case containing

SET SESSION debug="d,";
SELECT dl FROM mysql.plugin WHERE name='foo';

and run it with "./mtr --valgrind test". Look at master.err.
[30 Oct 2008 11:53] Øystein Grøvlen
I do not get the valgrind errors reported here when I run on the current head of mysql-6.0-backup.
[16 Dec 2008 18:29] Paul Dubois
Noted in 6.0.9 changelog.

Setting the debug system variable and executing a SELECT statement
resulted in a Valgrind warning.