Bug #58937 many valgrind errors after grouping by result of decimal column function
Submitted: 15 Dec 2010 6:09 Modified: 3 May 2011 0:54
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 OS:Any
Assigned to: CPU Architecture:Any

[15 Dec 2010 6:09] Shane Bester
Description:
5.5.9-debug:

Conditional jump or move depends on uninitialised value(s)
at: decimal_actual_fraction (decimal.c:294)
by: my_decimal2binary (my_decimal.cc:200)
by: Field_new_decimal::store_value (field.cc:2633)
by: Field_new_decimal::store_decimal (field.cc:2759)
by: Item::save_in_field (item.cc:5428)
by: Item_result_field::save_in_result_field (item.h:2420)
by: copy_funcs (sql_select.cc:15898)
by: end_write (sql_select.cc:12759)
by: evaluate_join_record (sql_select.cc:11787)
by: sub_select (sql_select.cc:11663)
by: do_select (sql_select.cc:11428)
by: JOIN::exec (sql_select.cc:1970)
by: mysql_select (sql_select.cc:2570)
by: handle_select (sql_select.cc:297)
by: execute_sqlcom_select (sql_parse.cc:4452)
by: mysql_execute_command (sql_parse.cc:2046)
by: mysql_parse (sql_parse.cc:5496)
by: dispatch_command (sql_parse.cc:1032)
by: do_command (sql_parse.cc:772)
by: do_handle_one_connection (sql_connect.cc:745)
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::save_in_field(Field*, bool) (item.cc:5383)

<cut - see attached file for many more valgrind errors>

How to repeat:
run mysqld in valgrind (see attached file for full details), then:

drop table if exists `t1`;
create table `t1`(`a` decimal(22,1))engine=myisam;
insert into `t1` values (0),(1);
select round(`a`,`a`) from `t1`; #invalid bytes in net layer
select round(`a`,`a`) from `t1` group by 1;
[15 Dec 2010 6:10] MySQL Verification Team
the full output has many scary valgrind warnings...

Attachment: bug58937_5.5.9_valgrind_output.txt (text/plain), 34.25 KiB.

[15 Dec 2010 8:26] Valeriy Kravchuk
Verified with current mysql-5.5-security tree on 32-bit Ubuntu 10.04:

==16106== Conditional jump or move depends on uninitialised value(s)
==16106==    at 0x8710332: decimal_actual_fraction (decimal.c:294)
==16106==    by 0x8458EF7: my_decimal2binary(unsigned int, my_decimal const*, unsigned char*, int, int) (my_decimal.cc:200)
==16106==    by 0x835516C: Field_new_decimal::store_value(my_decimal const*) (field.cc:2633)
==16106==    by 0x8355AA2: Field_new_decimal::store_decimal(my_decimal const*) (field.cc:2759)
==16106==    by 0x83931AF: Item::save_in_field(Field*, bool) (item.cc:5428)
==16106==    by 0x8221A86: Item_result_field::save_in_result_field(bool) (item.h:2420)
==16106==    by 0x8266780: copy_funcs(Item**, THD const*) (sql_select.cc:15898)
==16106==    by 0x825F2FB: end_write(JOIN*, st_join_table*, bool) (sql_select.cc:12759)
==16106==    by 0x825CACB: evaluate_join_record(JOIN*, st_join_table*, int) (sql_select.cc:11787)
==16106==    by 0x825C78F: sub_select(JOIN*, st_join_table*, bool) (sql_select.cc:11663)
==16106==    by 0x825C356: do_select(JOIN*, List<Item>*, TABLE*, Procedure*) (sql_select.cc:11428)
==16106==    by 0x824510E: JOIN::exec() (sql_select.cc:1970)
==16106==
[3 May 2011 0:54] Paul DuBois
Noted in 5.1.58, 5.5.13, 5.6.3 changelogs.

In ROUND() calculations, a Valgrind warning for uninitialized memory
was corrected. 

CHANGESET - http://lists.mysql.com/commits/135765
[24 Dec 2012 10:00] Erlend Dahl
Bug#57533 was marked as a duplicate.