Bug #59270 not in (year( ... ), ... ) produces many valgrind warnings
Submitted: 4 Jan 2011 7:56 Modified: 27 Apr 2011 18:43
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Data Types Severity:S2 (Serious)
Version:5.1.55,5.5.9,5.6.2 OS:Any
Assigned to: CPU Architecture:Any
Tags: valgrind, year
Triage: Triaged: D1 (Critical)

[4 Jan 2011 7:56] Shane Bester
Description:
Version: '5.6.2-m5-valgrind-max-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
Thread 18:
Conditional jump or move depends on uninitialised value(s)
at: cmp_longs (item_cmpfunc.cc:3359)
by: cmp_longlong (item_cmpfunc.cc:3432)
by: my_qsort2 (mf_qsort.c:130)
by: in_vector::sort (item_cmpfunc.h:822)
by: Item_func_in::fix_length_and_dec (item_cmpfunc.cc:4126)
by: Item_func::fix_fields (item_func.cc:227)
by: Item_func_in::fix_fields (item_cmpfunc.cc:3902)
by: setup_fields (sql_base.cc:7784)
by: mysql_do (sql_do.cc:31)
by: mysql_execute_command (sql_parse.cc:2119)
by: mysql_parse (sql_parse.cc:5550)
by: dispatch_command (sql_parse.cc:1078)
by: do_command (sql_parse.cc:815)
by: do_handle_one_connection (sql_connect.cc:748)
by: handle_one_connection (sql_connect.cc:684)
by: start_thread (pthread_create.c:301)
Uninitialised value was created by a stack allocation
at: Item_func_year::val_int() (item_timefunc.cc:1303)

See full output in attached file

How to repeat:
#run mysqld in valgrind, then:
do 1 not in (year(from_unixtime(1)),1);
[4 Jan 2011 7:57] Shane Bester
full outputs from valgrind

Attachment: bug59270_5.6.2_valgrind_output.txt (text/plain), 14.03 KiB.

[4 Jan 2011 8:05] Shane Bester
related: bug #59164
[4 Jan 2011 11:05] Valeriy Kravchuk
I do not see these warnings with 5.1.55-valgrind on 32-bit Ubuntu for some reason.
[4 Jan 2011 12:15] Valeriy Kravchuk
Can not repeat with the same 5.6.2-m5-valgrind-max-debug (built from current mysql-trunk) and valgrind started with -v --leak-check=full --tool=memcheck options.
[6 Jan 2011 8:41] Shane Bester
Hi Valeriy!

Sorry, I put wrong testcase in the how to repeat :)  Here is correct one:

 do 1 not in (year(from_unixtime(null)),1);
[6 Jan 2011 10:38] Valeriy Kravchuk
Verified with modified test case. This is from current mysql-trunk:

==1770== Conditional jump or move depends on uninitialised value(s)
==1770==    at 0x83B29BB: cmp_longs(long long, long long) (item_cmpfunc.cc:3359)
==1770==    by 0x83B2B4C: cmp_longlong(void*, in_longlong::packed_longlong*, in_longlong::packed_longlong*) (item_cmpfunc.cc:3432)
==1770==    by 0x83B2C87: in_vector::find(Item*) (item_cmpfunc.cc:3470)
==1770==    by 0x83B5635: Item_func_in::val_int() (item_cmpfunc.cc:4198)
==1770==    by 0x84856C8: mysql_do(THD*, List<Item>&) (sql_do.cc:34)
==1770==    by 0x8214446: mysql_execute_command(THD*) (sql_parse.cc:2119)
==1770==    by 0x821E0F7: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:5550)
==1770==    by 0x8211D06: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1078)
==1770==    by 0x8211091: do_command(THD*) (sql_parse.cc:815)
==1770==    by 0x82F0FDA: do_handle_one_connection(THD*) (sql_connect.cc:748)
==1770==    by 0x82F0BD8: handle_one_connection (sql_connect.cc:684)
==1770==    by 0x404196D: start_thread (pthread_create.c:300)
[27 Apr 2011 18:43] Paul Dubois
Noted in 5.1.58, 5.5.13, 5.6.3 changelogs.

In Item_func_in::fix_length_and_dec(), a Valgrind warning for
uninitialized values was corrected. 

CHANGESET - http://lists.mysql.com/commits/135243
[20 Jul 2011 14:29] Shane Bester
bug #60400 is a duplicate