Bug #44792 valgrind warning when casting from time to time
Submitted: 11 May 2009 14:03 Modified: 26 Jun 2009 2:28
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.0.82, 5.1.30, 5.1.34, .5.1.35, 6.0.10 OS:Linux (32-bit fc8)
Assigned to: Alexey Kopytov CPU Architecture:Any
Tags: cast, time, valgrind
Triage: Triaged: D2 (Serious)

[11 May 2009 14:03] Shane Bester
Description:
when casting from a time column to time, valgrind output warnings for 5.1.35:

Conditional jump or move depends on uninitialised value(s)
: Protocol_text::store_time(st_mysql_time*) (protocol.cc:998)
: Item::send(Protocol*, String*) (item.cc:5375)
: select_send::send_data(List<Item>&) (sql_class.cc:1587)
: end_send(JOIN*, st_join_table*, bool) (sql_select.cc:11976)
: do_select(JOIN*, List<Item>*, st_table*, Procedure*) (sql_select.cc:10854)
: JOIN::exec() (sql_select.cc:2199)
: mysql_select (sql_select.cc:2378)
: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:268)
: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5009)
: mysql_execute_command(THD*) (sql_parse.cc:2211)
: mysql_parse(THD*, char const*, unsigned, char const**) (sql_parse.cc:5929)
: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1216)

might be related to bug #43774 but i am not double casting anything here.

How to repeat:
#run mysqld under valgrind, then run the sql:

drop table if exists `tmp`;
create table `tmp`(`c2` time)engine=myisam;
insert into `tmp` values ('0:00:00');
select cast(`c2` as time) from `tmp` limit 1;

Suggested fix:
initialize the tm structure properly?
[15 May 2009 7:02] 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/74128

2741 Alexey Kopytov	2009-05-15
      Bug #44792: valgrind warning when casting from time to time
      
      Field_time::get_time() did not initialize some members of
      MYSQL_TIME which led to valgrind warnings when those members
      were accessed in Protocol_simple::store_time().
      
      It is unlikely that this bug could result in wrong data
      being returned, since Field_time::get_time() initializes the
      'days' member of MYSQL_TIME to 0, so the value of 'days'
      in Protocol_simple::store_time() would be 0 regardless
      of the values for 'year' and 'month'.
      modified:
        mysql-test/r/type_time.result
        mysql-test/t/type_time.test
        sql/field.cc
[15 May 2009 8:16] 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/74141

2741 Alexey Kopytov	2009-05-15
      Bug #44792: valgrind warning when casting from time to time 
       
      Field_time::get_time() did not initialize some members of 
      MYSQL_TIME which led to valgrind warnings when those members 
      were accessed in Protocol_simple::store_time(). 
       
      It is unlikely that this bug could result in wrong data 
      being returned, since Field_time::get_time() initializes the 
      'day' member of MYSQL_TIME to 0, so the value of 'day' 
      in Protocol_simple::store_time() would be 0 regardless 
      of the values for 'year' and 'month'.
      modified:
        mysql-test/r/type_time.result
        mysql-test/t/type_time.test
        sql/field.cc
[28 May 2009 7:41] Bugs System
Pushed into 5.0.83 (revid:joro@sun.com-20090528073529-q9b8s60vlpu28fny) (version source revid:alexey.kopytov@sun.com-20090515085440-q6pymsv2lillyxzg) (merge vers: 5.0.82) (pib:6)
[28 May 2009 8:17] Bugs System
Pushed into 5.1.36 (revid:joro@sun.com-20090528073639-yohsb4q1jzg7ycws) (version source revid:jimw@mysql.com-20090515174051-ndjvfd1e9hc9k9c3) (merge vers: 5.1.36) (pib:6)
[1 Jun 2009 16:42] Paul Dubois
Noted in 5.0.83, 5.1.36 changelogs.

Several Valgrind warnings were silenced.

Setting report to NDI pending push into 6.0.x.
[17 Jun 2009 19:24] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090616183122-chjzbaa30qopdra9) (version source revid:kristofer.pettersson@sun.com-20090515092117-d8kbrf2wwohyf7l5) (merge vers: 6.0.12-alpha) (pib:11)
[26 Jun 2009 2:28] Paul Dubois
Noted in 5.4.4 changelog.
[12 Aug 2009 22:28] Paul Dubois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[15 Aug 2009 1:47] Paul Dubois
Ignore previous comment about 5.4.2.
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[7 Oct 2009 19:33] Paul Dubois
The 5.4 fix has been pushed to 5.4.2.