Bug #42534 subselect3_jcl6 produces valgrind warnings with MTR2
Submitted: 2 Feb 2009 9:00 Modified: 22 Nov 2010 0:42
Reporter: Sergey Petrunya Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:6.0 OS:Any
Assigned to: Sergey Petrunya CPU Architecture:Any

[2 Feb 2009 9:00] Sergey Petrunya
Description:
In pushbuild1, one can see:

main.subselect3_jcl6                     [ fail ]  Found warnings/errors in server log file!
        Test ended at 2009-02-02 07:31:16
file_name	line
/dev/shm/var-ps_stm-121/mysqld.1/mysqld.err	==20984==    at 0x4A21767: memcpy (mc_replace_strmem.c:406)
/dev/shm/var-ps_stm-121/mysqld.1/mysqld.err	==20984==    at 0x4A1FA56: malloc (vg_replace_malloc.c:149)
/dev/shm/var-ps_stm-121/mysqld.1/mysqld.err	==20984==    at 0x4A21720: memcpy (mc_replace_strmem.c:406)
/dev/shm/var-ps_stm-121/mysqld.1/mysqld.err	==20984==    at 0x4A1FA56: malloc (vg_replace_malloc.c:149)
^ Found warnings!!
ok

 - saving '/dev/shm/var-ps_stm-121/log/main.subselect3_jcl6/' to '/dev/shm/var-ps_stm-121/log/main.subselect3_jcl6/'

How to repeat:
According to Gluh, the minimal testcase is:

set join_cache_level=6;
create table t1 (a int, b int, key(a));
insert into t1 values
 (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
create table t2 like t1;
insert into t2 select * from t1;
update t2 set b=1;
create table t3 (a int, oref int);
insert into t3 values (1, 1), (NULL,1), (NULL,0);
select a, oref,
      t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z
from t3;
drop table t1, t2, t3;
[3 Feb 2009 23:03] 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/65059

2691 Sergey Petrunia	2009-02-04
      BUG#42534: subselect3_jcl6 produces valgrind warnings with MTR2
      - Make JOIN_CACHE::reset() set last_rec_pos to point to the first record in the buffer, not
        to the byte right before the buffer.
[7 Feb 2009 20: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/65555

2691 Sergey Petrunia	2009-02-07
      BUG#42534: subselect3_jcl6 produces valgrind warnings with MTR2
      - Make JOIN_CACHE::reset() set last_rec_pos to point to the first record in the
        buffer, not to the byte right before the buffer.
      - Make JOIN_CACHE::read_all_record_fields() and JOIN_CACHE_BKA::get_next_key()
        handle the case when they're invoked for empty join buffer.
[16 Feb 2009 18:08] Bugs System
Pushed into 6.0.10-alpha (revid:alik@sun.com-20090216180446-dl1xovi02kbd2fgn) (version source revid:sergefp@mysql.com-20090212000815-9mmjyt0u6kx75r23) (merge vers: 6.0.10-alpha) (pib:6)
[24 Feb 2009 0:50] Paul DuBois
Noted in 6.0.10 changelog.

Certain queries could result in Valgrind warnings in the optimizer.
[16 Aug 2010 6:36] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100816062819-bluwgdq8q4xysmlg) (version source revid:alik@sun.com-20100816062612-enatdwnv809iw3s9) (pib:20)
[13 Nov 2010 16:18] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (merge vers: 5.6.99-m4) (pib:21)
[22 Nov 2010 0:42] Paul DuBois
Noted in 5.6.1 changelog.
[23 Nov 2010 2:21] Paul DuBois
Correction: No 5.6.1 changelog entry. Bug does not appear in any released 5.6.x version.