Bug #43612 | crash with explain extended, union, order by | ||
---|---|---|---|
Submitted: | 12 Mar 2009 20:42 | Modified: | 26 Jun 2009 2:08 |
Reporter: | Gary Pendergast | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S1 (Critical) |
Version: | 5.0.82, 5.1.32,5.1.35 | OS: | Any |
Assigned to: | Sergei Glukhov | CPU Architecture: | Any |
Tags: | crash, SELECT |
[12 Mar 2009 20:42]
Gary Pendergast
[6 May 2009 11:38]
MySQL Verification Team
5.1.35 valgrind output clearly shows the problem each time
Attachment: bug43612_5.1.35_valgrind_output.sql (application/unknown, text), 4.13 KiB.
[6 May 2009 12:04]
MySQL Verification Team
simpified testcase to cause the valgrind errors (and possible crash) drop table if exists `t1`; create table `t1`(`a` int); explain extended select `a` from `t1` union select `a` from `t1` order by `a`;
[12 May 2009 11:36]
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/73810 2735 Sergey Glukhov 2009-05-12 Bug#43612 crash with explain extended, union, order by In UNION if we use last SELECT without braces and this SELECT have ORDER BY clause, such clause belongs to global UNION. At this moment it is parsed like last SELECT part and used further as 'unit->global_parameters->order_list' value. So during DESCRIBE EXTENDED we call select_lex->print_order() for last SELECT where order fields refer to tmp table which already freed. It leads to crash. The fix is move such ORDER BY clause to global_parameters->order_list and cleanup last SELECT order_list. @ mysql-test/r/union.result test result @ mysql-test/t/union.test test case @ sql/sql_yacc.yy In UNION if we use last SELECT without braces and this SELECT have ORDER BY clause, such clause belongs to global UNION. At this moment it is parsed like last SELECT part and used further as 'unit->global_parameters->order_list' value. So during DESCRIBE EXTENDED we call select_lex->print_order() for last SELECT where order fields refer to tmp table which already freed. It leads to crash. The fix is move such ORDER BY clause to global_parameters->order_list and cleanup last SELECT order_list.
[15 May 2009 4:19]
MySQL Verification Team
Omer, this bug hits release and debug binaries. the valgrind output tell us this. however, some os's are more forgiving than others when it comes to this type of memory mismanagement. 64-bit windows binaries will always crash for example. some glibc linux versions will get a signal 6, and some will not even crash the first time.
[15 May 2009 7: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/74131 2735 Sergey Glukhov 2009-05-15 Bug#43612 crash with explain extended, union, order by In UNION if we use last SELECT without braces and this SELECT have ORDER BY clause, such clause belongs to global UNION. It is parsed like last SELECT part and used further as 'unit->global_parameters->order_list' value. During DESCRIBE EXTENDED we call select_lex->print_order() for last SELECT where order fields refer to tmp table which already freed. It leads to crash. The fix is clean up global_parameters->order_list instead of fake_select_lex->order_list. @ mysql-test/r/union.result test result @ mysql-test/t/union.test test case @ sql/sql_union.cc In UNION if we use last SELECT without braces and this SELECT have ORDER BY clause, such clause belongs to global UNION. It is parsed like last SELECT part and used further as 'unit->global_parameters->order_list' value. During DESCRIBE EXTENDED we call select_lex->print_order() for last SELECT where order fields refer to tmp table which already freed. It leads to crash. The fix is clean up global_parameters->order_list instead of fake_select_lex->order_list.
[15 May 2009 8:04]
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/74139 2741 Sergey Glukhov 2009-05-15 Bug#43612 crash with explain extended, union, order by In UNION if we use last SELECT without braces and this SELECT have ORDER BY clause, such clause belongs to global UNION. It is parsed like last SELECT part and used further as 'unit->global_parameters->order_list' value. During DESCRIBE EXTENDED we call select_lex->print_order() for last SELECT where order fields refer to tmp table which already freed. It leads to crash. The fix is clean up global_parameters->order_list instead of fake_select_lex->order_list. @ mysql-test/r/union.result test result @ mysql-test/t/union.test test case @ sql/sql_union.cc In UNION if we use last SELECT without braces and this SELECT have ORDER BY clause, such clause belongs to global UNION. It is parsed like last SELECT part and used further as 'unit->global_parameters->order_list' value. During DESCRIBE EXTENDED we call select_lex->print_order() for last SELECT where order fields refer to tmp table which already freed. It leads to crash. The fix is clean up global_parameters->order_list instead of fake_select_lex->order_list.
[28 May 2009 7:42]
Bugs System
Pushed into 5.0.83 (revid:joro@sun.com-20090528073529-q9b8s60vlpu28fny) (version source revid:sergey.glukhov@sun.com-20090515070334-t2bmuovmuw4kjzfe) (merge vers: 5.0.82) (pib:6)
[28 May 2009 8:17]
Bugs System
Pushed into 5.1.36 (revid:joro@sun.com-20090528073639-yohsb4q1jzg7ycws) (version source revid:jimw@mysql.com-20090515174051-ndjvfd1e9hc9k9c3) (merge vers: 5.1.36) (pib:6)
[1 Jun 2009 19:00]
Paul DuBois
Noted in 5.0.83, 5.1.36 changelogs. EXPLAIN EXTENDED could crash for UNION queries in which the last SELECT was not parenthesized and included an ORDER BY clause. Setting report to NDI pending push into 6.0.x.
[17 Jun 2009 19:24]
Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090616183122-chjzbaa30qopdra9) (version source revid:kristofer.pettersson@sun.com-20090515092117-d8kbrf2wwohyf7l5) (merge vers: 6.0.12-alpha) (pib:11)
[26 Jun 2009 2:08]
Paul DuBois
Noted in 5.4.4 changelog.
[12 Aug 2009 22:40]
Paul DuBois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[15 Aug 2009 1:56]
Paul DuBois
Ignore previous comment about 5.4.2.
[26 Aug 2009 13:46]
Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46]
Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48]
Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32]
Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[8 Oct 2009 2:48]
Paul DuBois
The 5.4 fix has been pushed to 5.4.2.