Bug #56567 mysql-test-run --valgrind innodb_plugin.innodb_bug52745 gives warnings
Submitted: 5 Sep 2010 10:45 Modified: 10 Feb 2011 14:51
Reporter: Michael Widenius Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB Plugin storage engine Severity:S2 (Serious)
Version:5.1.50, 5.1.51-bzr, 5.5 OS:Linux
Assigned to: Assigned Account CPU Architecture:Any
Tags: Contribution, valgrind

[5 Sep 2010 10:45] Michael Widenius
Description:
Running mysql test suite with valgrind shows warnings

How to repeat:
mysql-test-run --valgrind innodb_plugin.innodb_bug52745

line                                                                            
==25815== Thread 17:                                                            
==25815== Invalid read of size 1                                                
==25815==    at 0x6D00113: mach_read_from_4 (mach0data.ic:182)                  
==25815==    by 0x6C9BEFD: buf_buddy_relocate (buf0buddy.c:445)                 
==25815==    by 0x6C9C9DE: buf_buddy_free_low (buf0buddy.c:639)                 
==25815==    by 0x6C9AAB6: buf_buddy_free (buf0buddy.ic:121)                    
==25815==    by 0x6CA9C93: buf_LRU_block_remove_hashed_page (buf0lru.c:1828)    
==25815==    by 0x6CA6D57: buf_LRU_invalidate_tablespace (buf0lru.c:456)        
==25815==    by 0x6CC57CF: fil_delete_tablespace (fil0fil.c:2264)               
==25815==    by 0x6D42413: row_drop_table_for_mysql (row0mysql.c:3283)          
==25815==    by 0x6CDF6A7: ha_innodb::delete_table(char const*) (ha_innodb.cc:6973)                                                                             
==25815==    by 0x828B21: handler::ha_delete_table(char const*) (handler.cc:3373)                                                                               
==25815==    by 0x826070: ha_delete_table(THD*, handlerton*, char const*, char const*, char const*, bool) (handler.cc:1996)                                     
==25815==    by 0x849780: mysql_rm_table_part2(THD*, TABLE_LIST*, bool, bool, bool, bool) (sql_table.cc:2071)                                                   
==25815==    by 0x848DE6: mysql_rm_table(THD*, TABLE_LIST*, char, char) (sql_table.cc:1850)                                                                     
==25815==    by 0x6DEC09: mysql_execute_command(THD*) (sql_parse.cc:3431)       
==25815==    by 0x6E68BB: mysql_parse(THD*, char*, unsigned int, char const**) (sql_parse.cc:6032)                                                              
==25815==    by 0x6D8E77: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1260)                                                  
==25815==  Address 0x7d79422 is 5,154 bytes inside a  of size 16,384 client-defined                                                                             
==25815==    at 0x6C9E641: buf_block_init (buf0buf.c:650)                       
==25815==    by 0x6C9E843: buf_chunk_init (buf0buf.c:752)                       
==25815==    by 0x6C9EDA1: buf_pool_init (buf0buf.c:967)                        
==25815==    by 0x6D5BCB3: innobase_start_or_create_for_mysql (srv0start.c:1292)
==25815==    by 0x6CD759C: innobase_init(void*) (ha_innodb.cc:2250)             
==25815==    by 0x8231F4: ha_initialize_handlerton(st_plugin_int*) (handler.cc:435)                                                                             
==25815==    by 0x8F9730: plugin_initialize(st_plugin_int*) (sql_plugin.cc:1019)
==25815==    by 0x8F9FA5: plugin_init(int*, char**, int) (sql_plugin.cc:1246)   
==25815==    by 0x6CA95D: init_server_components() (mysqld.cc:3998)             
==25815==    by 0x6CB434: main (mysqld.cc:4469)
[5 Sep 2010 17:05] Valeriy Kravchuk
Verified with current 5.1.51 from bzr on Mac OS X. I've got different valgrind warning/errors. But still:

==24504== LEAK SUMMARY:
==24504==    definitely lost: 0 bytes in 0 blocks
==24504==    indirectly lost: 0 bytes in 0 blocks
==24504==      possibly lost: 20,752,004 bytes in 29,105 blocks
==24504==    still reachable: 8,593,715 bytes in 50,821 blocks
==24504==         suppressed: 340 bytes in 8 blocks
==24504== 
==24504== For counts of detected and suppressed errors, rerun with: -v
==24504== Use --track-origins=yes to see where uninitialised values come from
==24504== ERROR SUMMARY: 7474 errors from 428 contexts (suppressed: 0 from 0)
mysqltest failed but provided no output
[6 Sep 2010 8:34] Valeriy Kravchuk
Different warnings with current mysql5.1 from bzr on Ubuntu:

innodb_plugin.innodb_bug52745            [ fail ]  Found warnings/errors in server log file!
        Test ended at 2010-09-06 11:31:44
line
==21834== Conditional jump or move depends on uninitialised value(s)
==21834==    at 0x4F2307F: rw_lock_set_writer_id_and_recursion_flag (sync0rw.ic:283)
==21834==    by 0x4F23945: rw_lock_x_lock_low (sync0rw.c:555)
==21834==    by 0x4F23A0D: rw_lock_x_lock_func (sync0rw.c:614)
==21834==    by 0x4EDC8DC: mtr_x_lock_func (mtr0mtr.ic:271)
==21834==    by 0x4EA7537: fsp_header_init (fsp0fsp.c:970)
==21834==    by 0x4F217D4: innobase_start_or_create_for_mysql (srv0start.c:1491)
==21834==    by 0x4EB7BEF: innobase_init(void*) (ha_innodb.cc:2250)
==21834==    by 0x841C427: ha_initialize_handlerton(st_plugin_int*) (handler.cc:435)
==21834==    by 0x84EA2E9: plugin_initialize(st_plugin_int*) (sql_plugin.cc:1019)
==21834==    by 0x84EE801: plugin_init(int*, char**, int) (sql_plugin.cc:1246)
==21834==    by 0x82D0294: init_server_components() (mysqld.cc:3998)
==21834==    by 0x82D0D44: main (mysqld.cc:4469)
==21834== Conditional jump or move depends on uninitialised value(s)
==21834==    at 0x4F2307F: rw_lock_set_writer_id_and_recursion_flag (sync0rw.ic:283)
==21834==    by 0x4F23945: rw_lock_x_lock_low (sync0rw.c:555)
==21834==    by 0x4F23A0D: rw_lock_x_lock_func (sync0rw.c:614)
==21834==    by 0x4ED2B9E: log_group_checkpoint (log0log.c:1827)
==21834==    by 0x4ED2CC8: log_groups_write_checkpoint_info (log0log.c:1937)
==21834==    by 0x4ED2E5F: log_checkpoint (log0log.c:2025)
==21834==    by 0x4ED0869: log_fsp_current_free_limit_set_and_checkpoint (log0log.c:177)
==21834==    by 0x4EA81F2: fsp_fill_free_list (fsp0fsp.c:1402)
==21834==    by 0x4EA77A8: fsp_header_init (fsp0fsp.c:1004)
==21834==    by 0x4F217D4: innobase_start_or_create_for_mysql (srv0start.c:1491)
==21834==    by 0x4EB7BEF: innobase_init(void*) (ha_innodb.cc:2250)
==21834==    by 0x841C427: ha_initialize_handlerton(st_plugin_int*) (handler.cc:435)
==21834==    by 0x84EA2E9: plugin_initialize(st_plugin_int*) (sql_plugin.cc:1019)
==21834==    by 0x84EE801: plugin_init(int*, char**, int) (sql_plugin.cc:1246)
==21834==    by 0x82D0294: init_server_components() (mysqld.cc:3998)
==21834==    by 0x82D0D44: main (mysqld.cc:4469)
==21834== Conditional jump or move depends on uninitialised value(s)
==21834==    at 0x4F2307F: rw_lock_set_writer_id_and_recursion_flag (sync0rw.ic:283)
==21834==    by 0x4F23945: rw_lock_x_lock_low (sync0rw.c:555)
==21834==    by 0x4F23A0D: rw_lock_x_lock_func (sync0rw.c:614)
==21834==    by 0x4E7C7BF: btr_search_check_free_space_in_heap (btr0sea.c:145)
==21834==    by 0x4E7EC72: btr_search_update_hash_on_insert (btr0sea.c:1609)
==21834==    by 0x4E755A4: btr_cur_optimistic_insert (btr0cur.c:1242)
==21834==    by 0x4F028DE: row_ins_index_entry_low (row0ins.c:2099)
==21834==    by 0x4F02BBA: row_ins_index_entry (row0ins.c:2179)
==21834==    by 0x4F02DC0: row_ins_index_entry_step (row0ins.c:2264)
==21834==    by 0x4F02F7F: row_ins (row0ins.c:2396)
==21834==    by 0x4F0311A: row_ins_step (row0ins.c:2506)
==21834==    by 0x4EF9767: que_thr_step (que0que.c:1225)
==21834==    by 0x4EF99D8: que_run_threads_low (que0que.c:1311)
==21834==    by 0x4EF9AE9: que_run_threads (que0que.c:1348)
==21834==    by 0x4EF9CD5: que_eval_sql (que0que.c:1431)
==21834==    by 0x4E914DA: dict_create_or_check_foreign_constraint_tables (dict0crea.c:1256)
==21834== Thread 15:
==21834== Conditional jump or move depends on uninitialised value(s)
==21834==    at 0x4F2307F: rw_lock_set_writer_id_and_recursion_flag (sync0rw.ic:283)
==21834==    by 0x4F23945: rw_lock_x_lock_low (sync0rw.c:555)
==21834==    by 0x4F23A0D: rw_lock_x_lock_func (sync0rw.c:614)
==21834==    by 0x4F28337: trx_purge (trx0purge.c:1107)
==21834==    by 0x4F1F4CF: srv_master_thread (srv0srv.c:2685)
==21834==    by 0x404196D: start_thread (pthread_create.c:300)
==21834==    by 0x4196A4D: clone (clone.S:130)
==21834== Thread 17:
==21834== Conditional jump or move depends on uninitialised value(s)
==21834==    at 0x8791462: longest_match (deflate.c:1143)
==21834==    by 0x87923D5: deflate_slow (deflate.c:1595)
==21834==    by 0x8790906: deflate (deflate.c:790)
==21834==    by 0x4E79BC8: btr_store_big_rec_extern_fields (btr0cur.c:3972)
==21834==    by 0x4F02AAE: row_ins_index_entry_low (row0ins.c:2131)
==21834==    by 0x4F02BBA: row_ins_index_entry (row0ins.c:2179)
==21834==    by 0x4F02DC0: row_ins_index_entry_step (row0ins.c:2264)
==21834==    by 0x4F02F7F: row_ins (row0ins.c:2396)
==21834==    by 0x4F0311A: row_ins_step (row0ins.c:2506)
==21834==    by 0x4F0863C: row_insert_for_mysql (row0mysql.c:1140)
==21834==    by 0x4EBFCB6: ha_innodb::write_row(unsigned char*) (ha_innodb.cc:4741)
==21834==    by 0x8417ABD: handler::ha_write_row(unsigned char*) (handler.cc:4654)
==21834==    by 0x837A47D: write_record(THD*, st_table*, st_copy_info*) (sql_insert.cc:1606)
==21834==    by 0x837F11D: mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) (sql_insert.cc:835)
==21834==    by 0x82E27A2: mysql_execute_command(THD*) (sql_parse.cc:3225)
==21834==    by 0x82E937E: mysql_parse(THD*, char const*, unsigned int, char const**) (sql_parse.cc:6017)
^ Found warnings in /home2/openxs/dbs/5.1/mysql-test/var/log/mysqld.1.err
[6 Sep 2010 10:53] Marko Mäkelä
This looks like a duplicate of Bug #47873: bogus Valgrind errors reported for InnoDB rw-locks implemented with atomic memory access. Did you forget to enable UNIV_DEBUG_VALGRIND or enable Valgrind support at build time?
[6 Oct 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[27 Dec 2010 22:52] Mark Callaghan
We get this in 5.5.8 and the 5.1.52 plugin when using the plugin for all innodb tests. This diff fixes it

--- /s/src/mysql-5.5.8/storage/innobase/buf/buf0buddy.c	2010-12-03 09:58:26.000000000 -0800
+++ storage/innobase/buf/buf0buddy.c	2010-12-27 14:48:51.000000000 -0800
@@ -438,6 +438,12 @@
 		/* This is a compressed page. */
 		mutex_t*	mutex;
 
+		/* Suppress Valgrind warnings about conditional jump
+		on uninitialized value. */
+		UNIV_MEM_VALID((const byte*) src +
+			FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 4);
+		UNIV_MEM_VALID((const byte*) src + FIL_PAGE_OFFSET, 4);
+
 		/* The src block may be split into smaller blocks,
 		some of which may be free.  Thus, the
 		mach_read_from_4() calls below may attempt to read
@@ -450,10 +456,6 @@
 			(const byte*) src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
 		ulint		page_no	= mach_read_from_4(
 			(const byte*) src + FIL_PAGE_OFFSET);
-		/* Suppress Valgrind warnings about conditional jump
-		on uninitialized value. */
-		UNIV_MEM_VALID(&space, sizeof space);
-		UNIV_MEM_VALID(&page_no, sizeof page_no);
 		bpage = buf_page_hash_get(buf_pool, space, page_no);
 
 		if (!bpage || bpage->zip.data != src) {
[6 Jan 2011 0:46] Mark Callaghan
I get the error with -DUNIV_DEBUG_VALGRIND set
[6 Jan 2011 0:51] Mark Callaghan
AFAIK, this problem occurs with gcc 4.4 but not with gcc 4.1
[6 Jan 2011 4:47] MySQL Verification Team
Verified on Centos 5.4 x86_64 using mysql-5.1.52.tar.gz and gcc 4.1:

./configure --enable-thread-safe-client --with-ssl \
--with-plugins=partition,csv,blackhole,myisam,heap,innodb_plugin,innobase \
--with-fast-mutexes --with-extra-charsets=all --with-debug \
C_EXTRA_FLAGS="-fno-omit-frame-pointer -fno-strict-aliasing -DHAVE_purify -DNO_ALARM -DSIGNAL_WITH_VIO_CLOSE -DUNIV_DEBUG_VALGRIND -Wall" \
CFLAGS="-O0 -g" CXXFLAGS="-O0 -g"
make
cd mysql-test
./mysql-test-run --valgrind innodb_plugin.innodb_bug52745
[6 Jan 2011 23:41] MySQL Verification Team
Verified on Centos 5.4 x86_64 using mysql-5.1.54.tar.gz and gcc 4.1:

./configure --enable-thread-safe-client --with-ssl \
--with-plugins=partition,csv,blackhole,myisam,heap,innodb_plugin,innobase \
--with-fast-mutexes --with-extra-charsets=all --with-debug \
--enable-mysql-maintainer-mode=no \
C_EXTRA_FLAGS="-fno-omit-frame-pointer -fno-strict-aliasing -DHAVE_purify -DNO_ALARM
-DSIGNAL_WITH_VIO_CLOSE -DUNIV_DEBUG_VALGRIND -Wall" \
CFLAGS="-O0 -g" CXXFLAGS="-O0 -g"
make
cd mysql-test
./mysql-test-run --valgrind innodb_plugin.innodb_bug52745

(note workaround for bug 57989)
[5 Feb 2011 5:05] Vasil Dimov
Probably a duplicate of Bug#59875 Valgrind warning in buf0buddy.c
[10 Feb 2011 14:51] Vasil Dimov
Duplicate of Bug#59875 Valgrind warning in buf0buddy.c
[15 Feb 2011 8:59] Marko Mäkelä
We are comparing x==x with uninitialized x, and this triggers a Valgrind warning when InnoDB has been built without Valgrind instrumentation. I have submitted a fix for this in Bug #59307.
[15 Feb 2011 9:00] Marko Mäkelä
My previous comment was referring to [6 Sep 2010 10:34] Valeriy Kravchuk