Bug #46003 Valgrind warning in JOIN::init()
Submitted: 7 Jul 2009 12:16 Modified: 7 Aug 2009 20:28
Reporter: Georgi Kodinov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.1-bk OS:Linux (Fedora 10)
Assigned to: Georgi Kodinov CPU Architecture:Any

[7 Jul 2009 12:16] Georgi Kodinov
Description:
I get valgrind warnings like this:
==29177== Source and destination overlap in memcpy(0x4E461A8, 0x4E461A8, 28)
==29177==    at 0x4A0827A: memcpy (mc_replace_strmem.c:402)
==29177==    by 0x6407FE: JOIN::init(THD*, List<Item>&, unsigned long long, sele
ct_result*) (sql_select.h:469)
==29177==    by 0x64094F: JOIN::JOIN(THD*, List<Item>&, unsigned long long, sele
ct_result*) (sql_select.h:418)
==29177==    by 0x72C18F: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int,
 List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsig
ned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.
cc:2361)
==29177==    by 0x73185C: handle_select(THD*, st_lex*, select_result*, unsigned 
long) (sql_select.cc:268)
==29177==    by 0x69C454: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc
:5012)
==29177==    by 0x69E345: mysql_execute_command(THD*) (sql_parse.cc:2207)
==29177==    by 0x85E0D4: sp_instr_stmt::exec_core(THD*, unsigned int*) (sp_head
.cc:2907)
==29177==    by 0x85E30C: sp_lex_keeper::reset_lex_and_exec_core(THD*, unsigned 
int*, bool, sp_instr*) (sp_head.cc:2735)
==29177==    by 0x86448E: sp_instr_stmt::execute(THD*, unsigned int*) (sp_head.c
c:2849)
==29177==    by 0x86060D: sp_head::execute(THD*) (sp_head.cc:1253)
==29177==    by 0x86139C: sp_head::execute_procedure(THD*, List<Item>*) (sp_head
.cc:1983)
==29177==    by 0x6A4EC7: mysql_execute_command(THD*) (sql_parse.cc:4353)
==29177==    by 0x6A7211: mysql_parse(THD*, char const*, unsigned int, char cons
t**) (sql_parse.cc:5932)
==29177==    by 0x6A8004: dispatch_command(enum_server_command, THD*, char*, uns
igned int) (sql_parse.cc:1213)
==29177==    by 0x6A936C: do_command(THD*) (sql_parse.cc:854) 

How to repeat:
run mysql-test-run.sh --valgrind group_by using valgrind-3.4.0.SVN

Suggested fix:
The JOIN constructor sets fields_list to fields_arg twice : once in an initializer and again in JOIN::init via an assignment.
Fix by either implementing a JOIN::equals() method and comparing the fields_list in JOIN::init() or renaming JOIN::init() to JOIN::init_innter(), taking out the assignment from it and moving to a JOIN::init() that will call JOIN::init_inner() and call JOIN::init_inner from the constructor.
[7 Jul 2009 12:28] 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/78121

3007 Georgi Kodinov	2009-07-07
      Bug #46003: Valgrind warning in JOIN::init()
      
      Don't do double initialization of JOIN::fields_list
      in JOIN::init().
[8 Jul 2009 14:40] 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/78222

2801 Georgi Kodinov	2009-07-08
      Bug #46003 and bug #46034: backported the fixes from azalea.
[16 Jul 2009 12:18] 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/78836

2801 Georgi Kodinov	2009-07-16
      Bug #46003 and bug #46034: backported the fixes from azalea.
      
      ******
      Bug #46042: backported the fix for the valgrind warning from 5.1
[16 Jul 2009 13:19] 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/78847

2785 Georgi Kodinov	2009-07-16
      Bug #46003 and bug #46034: backported the fixes from azalea.
[16 Jul 2009 15:26] 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/78867

2801 Georgi Kodinov	2009-07-16
      Bug #46003 and bug #46034: backported the fixes from azalea.
[4 Aug 2009 13:57] Bugs System
Pushed into 5.0.85 (revid:davi.arnaut@sun.com-20090804135315-6lfdnk4zjwk7kn7r) (version source revid:davi.arnaut@sun.com-20090804135315-6lfdnk4zjwk7kn7r) (merge vers: 5.0.85) (pib:11)
[4 Aug 2009 19:51] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090804194615-h40sa098mx4z49qg) (version source revid:dao-gang.qu@sun.com-20090717025250-n2lq5mqibjfdpigu) (merge vers: 5.4.4-alpha) (pib:11)
[4 Aug 2009 20:45] Bugs System
Pushed into 5.1.38 (revid:davi.arnaut@sun.com-20090804204317-ggodqkik7de6nfpz) (version source revid:davi.arnaut@sun.com-20090804204317-ggodqkik7de6nfpz) (merge vers: 5.1.38) (pib:11)
[7 Aug 2009 20:28] Paul DuBois
Noted in 5.0.85, 5.1.38, 5.4.4 changelogs.

Several Valgrind warnings were corrected.
[12 Aug 2009 22:10] Paul DuBois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[14 Aug 2009 23:01] Paul DuBois
Ignore previous comment about 5.4.2.
[1 Oct 2009 5:59] Bugs System
Pushed into 5.1.39-ndb-6.3.28 (revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (version source revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (merge vers: 5.1.39-ndb-6.3.28) (pib:11)
[1 Oct 2009 7:25] Bugs System
Pushed into 5.1.39-ndb-7.0.9 (revid:jonas@mysql.com-20091001072547-kv17uu06hfjhgjay) (version source revid:jonas@mysql.com-20091001071652-irejtnumzbpsbgk2) (merge vers: 5.1.39-ndb-7.0.9) (pib:11)
[1 Oct 2009 13:25] Bugs System
Pushed into 5.1.39-ndb-7.1.0 (revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (version source revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (merge vers: 5.1.39-ndb-7.1.0) (pib:11)
[5 Oct 2009 10:50] Bugs System
Pushed into 5.1.39-ndb-6.2.19 (revid:jonas@mysql.com-20091005103850-dwij2dojwpvf5hi6) (version source revid:jonas@mysql.com-20090930185117-bhud4ek1y0hsj1nv) (merge vers: 5.1.39-ndb-6.2.19) (pib:11)
[7 Oct 2009 16:23] Paul DuBois
The 5.4 fix has been pushed to 5.4.2.