Bug #38479 valgrind warnings in show table status for innodb tables
Submitted: 31 Jul 2008 7:31 Modified: 17 Jul 2009 2:56
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.0.66a, 5.0.74, 5.0.82 OS:Linux
Assigned to: Satya B CPU Architecture:Any

[31 Jul 2008 7:31] Shane Bester
Description:
'show table status' got this when running under valgrind

Version: '5.0.66a-enterprise-gpl-debug-log'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Enterprise Server - Debug (GPL)
 REDIR: 0x375350 (strnlen) redirected to 0x4006240 (strnlen)
 Thread 10:
 Conditional jump or move depends on uninitialised value(s)
0x8257CDA: build_template (ha_innodb.cc:2929)
0x8258F7A: ha_innobase::change_active_index (ha_innodb.cc:3977)
0x8258B86: ha_innobase::index_init (ha_innodb.cc:3669)
0x825CBAF: ha_innobase::innobase_read_and_init_auto_inc (ha_innodb.cc:6865)
0x825AEBD: ha_innobase::info (ha_innodb.cc:5534)
0x8274E44: get_schema_tables_record (sql_show.cc:2491)
0x82747DA: get_all_tables (sql_show.cc:2360)
0x8279B06: get_schema_tables_result (sql_show.cc:4071)
0x81DC5BF: JOIN::exec (sql_select.cc:1687)
0x81DDC0A: mysql_select (sql_select.cc:2274)
0x81D91CE: handle_select (sql_select.cc:245)
0x81A89D4: mysql_execute_command(THD*) (sql_parse.cc:2721)

that code triggering this is:
if (templ_type == ROW_MYSQL_REC_FIELDS) {
     if (prebuilt->hint_need_to_fetch_extra_cols
		== ROW_RETRIEVE_ALL_COLS) {

How to repeat:
will find time later for testcase.

[sbester@box1 mysql-enterprise-gpl-5.0.66a-linux-i686-glibc23]$ valgrind --tool=memcheck   --leak-check=yes -v --show-reachable=yes  ./bin/mysqld-debug --defaults-file=./data/my.c40.txt --skip-grant-tables --skip-name-resolve  --basedir=. --datadir=./data
[31 Jul 2008 13:11] MySQL Verification Team
5.1.26-rc had no such problems. verified on 5.0.66a:
1) start mysqld-debug with --innodb_file_per_table
2) create table t1(id int not null auto_increment primary key)engine=innodb;
3) shutdown mysqld-debug
4) start mysqld-debug under valgrind 
5) mysql -uroot -A test
6) show table status
[17 Oct 2008 0:24] Mark Callaghan
I have begun porting the big patch from 5.0.37 to 5.0.67 and just noticed it. When will it be fixed?
[17 Oct 2008 0:42] Mark Callaghan
I get this when the 'innodb' test is run.  The warning is for hint_need_to_fetch_extra_cols. That field is not set in row_create_prebuilt(). I think it should be.

     ulint           hint_need_to_fetch_extra_cols;
                                        /* normally this is set to 0; if this
                                        is set to ROW_RETRIEVE_PRIMARY_KEY,
                                        then we should at least retrieve all
                                        columns in the primary key; if this
                                        is set to ROW_RETRIEVE_ALL_COLS, then
                                        we must retrieve all columns in the
                                        key (if read_just_key == 1), or all
[20 Oct 2008 15:22] Mikhail Izioumtchenko
Mark, thank you for noticing. It's a bit surprising that valgrind complained the way it did, instead of delivering a plain English message about use of uninitialized memory which I'm a bit more accustomed to paying attention. Something that mentions 'unconditional jump' I grew to ignore since valgrind used to have problems with the branch optimization instruction sequences.
Vasil, I think a one line addition to the initialization function should do it,
but I still don't feel myself familiar with the code well enough so I'll leave it to you. Setting the triage values based on my assumption, though. P2 because it's easy to fix and using uninitialized memory is bad.
[20 Oct 2008 17:33] Vasil Dimov
Can someone check whether this patch silences the warning:

Index: row/row0mysql.c
===================================================================
--- row/row0mysql.c	(revision 2827)
+++ row/row0mysql.c	(working copy)
@@ -621,13 +621,15 @@ row_create_prebuilt(
 	prebuilt->mysql_template = NULL;
 
 	prebuilt->heap = heap;
 	prebuilt->ins_node = NULL;
 
 	prebuilt->ins_upd_rec_buff = NULL;
-	
+
+	prebuilt->hint_need_to_fetch_extra_cols = 0;
+
 	prebuilt->upd_node = NULL;
 	prebuilt->ins_graph = NULL;
 	prebuilt->upd_graph = NULL;
 
   	prebuilt->pcur = btr_pcur_create_for_mysql();
   	prebuilt->clust_pcur = btr_pcur_create_for_mysql();

Thank you!
[20 Oct 2008 17:34] Vasil Dimov
Potential patch to silence the warning.

Attachment: bug38479.diff (application/octet-stream, text), 586 bytes.

[21 May 2009 17:31] Vasil Dimov
I cannot reproduce this with latest MySQL-5.0.83 from BZR or with 5.0.51b or with 5.0.67.
[22 May 2009 7:55] MySQL Verification Team
still happens on my Version: '5.0.74-enterprise-gpl'.  will test newer versions shortly, then test the proposed patch if it still happens...
[22 May 2009 8:00] MySQL Verification Team
still happens on 5.0.82...
[22 May 2009 8:04] Vasil Dimov
Can you give some more details? What configure options did you use to compile MySQL and how did you start mysqld and valgrind?
[22 May 2009 8:50] MySQL Verification Team
Vasil, here's more details. I will rebuild and try that patch next.

Attachment: bug38479_5.0.82_build_and_valgrind_infos.txt (text/plain), 20.63 KiB.

[22 May 2009 9:39] MySQL Verification Team
Vasil, your proposed patch works on my 5.0.82.. no more warnings..
[22 May 2009 11:42] Vasil Dimov
Shane, thank you so much! I will now commit the patch...
[25 Jun 2009 9:36] 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/77129

2784 Satya B	2009-06-25
      Applying InnoDB snashot 5.0-ss5406, part 1. Fixes BUG#38479
      
      BUG#38479 - valgrind warnings in show table status for innodb tables
      
      Detailed revision comments:
      
      r5080 | vasil | 2009-05-22 14:45:34 +0300 (Fri, 22 May 2009) | 6 lines
      branches/5.0:
      
      Fix Bug#38479 valgrind warnings in show table status for innodb tables
      
      by initializing prebuilt->hint_need_to_fetch_extra_cols.
      modified:
        innobase/row/row0mysql.c
[7 Jul 2009 7:52] Bugs System
Pushed into 5.0.84 (revid:joro@sun.com-20090707074938-ksah1ibn0vs92cem) (version source revid:satya.bn@sun.com-20090625093612-jol72av09zl81w7d) (merge vers: 5.0.84) (pib:11)
[8 Jul 2009 13:30] Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090708131116-kyz8iotbum8w9yic) (version source revid:staale.smedseng@sun.com-20090626084621-g6zteyvzehto95j0) (merge vers: 5.1.37) (pib:11)
[9 Jul 2009 7:35] Bugs System
Pushed into 5.0.84 (revid:joro@sun.com-20090707074938-ksah1ibn0vs92cem) (version source revid:satya.bn@sun.com-20090625093612-jol72av09zl81w7d) (merge vers: 5.0.84) (pib:11)
[9 Jul 2009 7:37] Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090708131116-kyz8iotbum8w9yic) (version source revid:staale.smedseng@sun.com-20090626084621-g6zteyvzehto95j0) (merge vers: 5.1.37) (pib:11)
[10 Jul 2009 11:21] Bugs System
Pushed into 5.4.4-alpha (revid:anozdrin@bk-internal.mysql.com-20090710111017-bnh2cau84ug1hvei) (version source revid:sergey.glukhov@sun.com-20090625092510-lq3mm6ytxb2ldfim) (merge vers: 5.4.4-alpha) (pib:11)
[17 Jul 2009 2:56] Paul DuBois
Noted in 5.0.84, 5.1.37, 5.4.4 changelogs.

Valgrind warnings that occurred for SHOW TABLE STATUS with InnoDB
tables were silenced.
[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:33] 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)
[11 Mar 2010 18:03] Paul DuBois
Noted in 5.5.3 changelog.