Bug #56611 valgrind: Uninitialised bytes found on server startup in buf_LRU_free_block()
Submitted: 7 Sep 2010 11:05 Modified: 8 Feb 2011 23:04
Reporter: John Embretsen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.6.1 OS:Linux
Assigned to: Sunny Bains CPU Architecture:Any
Triage: Triaged: D1 (Critical) / R1 (None/Negligible) / E1 (None/Negligible)

[7 Sep 2010 11:05] John Embretsen
Description:
Starting mysqld with InnoDB as default storage engine (default in 5.6.*) with valgrind memcheck enabled results in the following valgrind warning:

==13948== Uninitialised byte(s) found during client check request
==13948==    at 0x99955E: buf_LRU_free_block (buf0lru.c:1556)
==13948==    by 0x997F5F: buf_LRU_free_from_common_LRU_list (buf0lru.c:675)
==13948==    by 0x99804D: buf_LRU_search_and_free_block (buf0lru.c:731)
==13948==    by 0x993506: buf_pool_invalidate_instance (buf0buf.c:4355)
==13948==    by 0x9935B1: buf_pool_invalidate (buf0buf.c:4386)
==13948==    by 0x95D010: innobase_start_or_create_for_mysql (srv0start.c:1604)
==13948==    by 0x9291CC: innobase_init(void*) (ha_innodb.cc:2437)
==13948==    by 0x723B70: ha_initialize_handlerton(st_plugin_int*) (handler.cc:464)
==13948==    by 0x5DDD4D: plugin_initialize(st_plugin_int*) (sql_plugin.cc:1037)
==13948==    by 0x5E1C38: plugin_init(int*, char**, int) (sql_plugin.cc:1323)
==13948==    by 0x54E543: init_server_components() (mysqld.cc:4023)
==13948==    by 0x54FCF3: mysqld_main(int, char**) (mysqld.cc:4589)
==13948==    by 0x544A36: main (main.cc:24)
==13948==  Address 0x792700c is not stack'd, malloc'd or (recently) free'd
==13948==  Uninitialised value was created by a client request
==13948==    at 0x9EA051: os_mem_alloc_large (os0proc.c:171)
==13948==    by 0x98E363: buf_chunk_init (buf0buf.c:935)
==13948==    by 0x98E9EE: buf_pool_init_instance (buf0buf.c:1220)
==13948==    by 0x98ECFC: buf_pool_init (buf0buf.c:1324)
==13948==    by 0x95CBCF: innobase_start_or_create_for_mysql (srv0start.c:1337)
==13948==    by 0x9291CC: innobase_init(void*) (ha_innodb.cc:2437)
==13948==    by 0x723B70: ha_initialize_handlerton(st_plugin_int*) (handler.cc:464)
==13948==    by 0x5DDD4D: plugin_initialize(st_plugin_int*) (sql_plugin.cc:1037)
==13948==    by 0x5E1C38: plugin_init(int*, char**, int) (sql_plugin.cc:1323)
==13948==    by 0x54E543: init_server_components() (mysqld.cc:4023)
==13948==    by 0x54FCF3: mysqld_main(int, char**) (mysqld.cc:4589)
==13948==    by 0x544A36: main (main.cc:24)
/data0/code/bzr/mysql-trunk-bugfixing-valgrind/storage/innobase/buf/buf0lru.c:1556: 0x7927000[104] undefined at 12

Using InnoDB 1.2.0 in MySQL 5.6.1 (mysql-trunk-bugfixing, revision 3258 mats.kindahl@oracle.com-20100906125204-ofptc0bwgc1d5bdi) or mysql-next-mr-bugfixing (5.6.99, revision 3274 jorgen.loland@oracle.com-20100906072738-ugb051ustfp90ox9).

Issue does not seem to be present with mysql-5.5 or mysql-5.1-bugteam bzr branches as of 2010-09-06.

Observed on a Ubuntu 9.04 64-bit host.

How to repeat:
Branch and build mysql-next-mr-bugfixing or mysql-trunk-bugfixing with valgrind enabled (e.g. use BUILD/compile-amd64-valgrind-max to build).

Start the server with valgrind, either by prepending the following to the server startup command:

valgrind --tool=memcheck --leak-check=yes --track-origins=yes --read-var-info=yes --num-callers=16 --show-reachable=yes <mysqld_command_line>

or by running MTR:

perl ./mysql-test-run.pl --valgrind 1st

Then check the output and/or the server error log file (var/log/mysqld1.err in the case of MTR).
[14 Oct 2010 4:17] Sunny Bains
In the same function we already have this:

#if UNIV_WORD_SIZE == 4
        /* On 32-bit systems, there is no padding in buf_page_t.  On
        other systems, Valgrind could complain about uninitialized pad
        bytes. */
        UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage);
#endif

The other problematic line needs to be in a #ifdef too.
[13 Nov 2010 16:13] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:38] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (pib:21)