Bug #46853 valgrind warnings in mysql-pe branch with the testcase for the BUG#45816
Submitted: 21 Aug 2009 11:07 Modified: 25 Nov 2009 18:51
Reporter: Satya B Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: valgrind

[21 Aug 2009 11:07] Satya B
Description:
The testcase introduced with BUG#45816 generates valgrind warnings on mysql-pe branch

I was able to reproduce the valgrind warnings even after removing the patch(code part) for BUG#45816.

the warnings are generated from this code :

if (copy->field && copy->field->maybe_null() && copy->field->is_null())

and the cause seems to be this method copy->field->is_null()

is_null() is defined in sql/field.h as follows.

 inline bool is_null(my_ptrdiff_t row_offset= 0)
 { return null_ptr ? (null_ptr[0] & null_bit ? 1 : 0) : table->null_row; }

null_bit is uninitialized here and causes the valgrind warnings 

stack trace:
===========

=4965== Thread 3:
==4965== Conditional jump or move depends on uninitialised value(s)
==4965==    at 0x82FD040: JOIN_CACHE::write_record_data(unsigned char*, bool*) (sql_join_cache.cc:1028)
==4965==    by 0x82FD6A6: JOIN_CACHE::put_record() (sql_join_cache.cc:1187)
==4965==    by 0x832D207: sub_select_cache(JOIN*, st_join_table*, bool) (sql_select.cc:16073)
==4965==    by 0x832CCA7: evaluate_join_record(JOIN*, st_join_table*, int) (sql_select.cc:16525)
==4965==    by 0x832CF45: sub_select(JOIN*, st_join_table*, bool) (sql_select.cc:16262)
==4965==    by 0x833A2D2: do_select(JOIN*, List<Item>*, TABLE*, Procedure*) (sql_select.cc:15821)
==4965==    by 0x835230C: JOIN::exec() (sql_select.cc:2900)
==4965==    by 0x834CB59: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:3091)
==4965==    by 0x835261C: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:306)
==4965==    by 0x82B0B80: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4927)
==4965==    by 0x82B2BB4: mysql_execute_command(THD*) (sql_parse.cc:2112)
==4965==    by 0x82BC0A1: mysql_parse(THD*, char const*, unsigned int, char const**) (sql_parse.cc:5942)
==4965==    by 0x82BCBFB: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1062)
==4965==    by 0x82BE120: do_command(THD*) (sql_parse.cc:744)
==4965==    by 0x82AA6B7: handle_one_connection (sql_connect.cc:1158)
==4965==    by 0x40544FE: start_thread (in /lib/tls/i686/cmov/libpthread-2.9.so)
==4965==

==4965== Conditional jump or move depends on uninitialised value(s)
==4965==    at 0x82FC492: JOIN_CACHE::read_record_field(st_cache_field*, bool) (sql_join_cache.cc:1398)
==4965==    by 0x82FCC1C: JOIN_CACHE::read_all_record_fields() (sql_join_cache.cc:1336)
==4965==    by 0x82FCD37: JOIN_CACHE::get_record() (sql_join_cache.cc:1229)
==4965==    by 0x82FC39E: JOIN_CACHE_BNL::join_matching_records(bool) (sql_join_cache.cc:1800)
==4965==    by 0x82FAA2B: JOIN_CACHE::join_records(bool) (sql_join_cache.cc:1617)
==4965==    by 0x832D177: sub_select_cache(JOIN*, st_join_table*, bool) (sql_select.cc:16060)
==4965==    by 0x832CE07: sub_select(JOIN*, st_join_table*, bool) (sql_select.cc:16218)
==4965==    by 0x833A301: do_select(JOIN*, List<Item>*, TABLE*, Procedure*) (sql_select.cc:15823)
==4965==    by 0x835230C: JOIN::exec() (sql_select.cc:2900)
==4965==    by 0x834CB59: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:3091)
==4965==    by 0x835261C: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:306)
==4965==    by 0x82B0B80: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:4927)
==4965==    by 0x82B2BB4: mysql_execute_command(THD*) (sql_parse.cc:2112)
==4965==    by 0x82BC0A1: mysql_parse(THD*, char const*, unsigned int, char const**) (sql_parse.cc:5942)
==4965==    by 0x82BCBFB: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1062)
==4965==    by 0x82BE120: do_command(THD*) (sql_parse.cc:744)

How to repeat:
in mysql-pe branch

build using ./BUILD/compile-pentium-valgrind-max-no-ndb 

and run the test case at attached (with valgrind)

./mtr partition_valgrind_warnings.test --valgrind
[21 Aug 2009 11:09] Satya B
testcase to reproduce valgrind warnings

Attachment: partition_valgrind_warnings.test (application/octet-stream, text), 472 bytes.

[21 Aug 2009 11:42] 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/81277

3521 Satya B	2009-08-21
      Disable the testcase for BUG#45816 in partition.test in mysql-pe branch due to BUG#46853
      
      Commented out the testcase for Bug#45816 in mysql-pe branch
      due to valgrind warnings. Please see Bug#46853
      modified:
        mysql-test/r/partition.result
        mysql-test/t/partition.test
[14 Sep 2009 16:06] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (version source revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (merge vers: 5.4.4-alpha) (pib:11)
[25 Nov 2009 18:50] 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/91693

2943 Magne Mahre	2009-11-25
      Disable the testcase for BUG#45816 in partition.test in mysql-pe 
      branch due to BUG#46853
            
      Commented out the testcase for Bug#45816 in mysql-pe branch
      due to valgrind warnings. Please see Bug#46853
[25 Nov 2009 19:27] Magne Mæhre
Test case changes has been backported to 5.6.0 and pushed to next-mr-runtime.
6.0-codebase revid: 3520.1.1
[8 Dec 2009 6:45] Bugs System
Pushed into 6.0.14-alpha (revid:alik@ibmvm-20091208064346-e7bavsqpl86x26dy) (version source revid:alik@ibmvm-20091208064346-e7bavsqpl86x26dy) (merge vers: 6.0.14-alpha) (pib:13)
[8 Dec 2009 6:46] Bugs System
Pushed into 5.6.0-beta (revid:alik@ibmvm-20091207060840-4j0ks51bxwcsln6y) (version source revid:magne.mahre@sun.com-20091125184930-c00efnej2x1i01zm) (merge vers: 5.6.0-beta) (pib:13)
[6 Mar 2010 11:07] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@mysql.com-20091210104731-27nl9weemor51ige) (merge vers: 5.6.0-beta) (pib:16)