[MDEV-4250] Server crashes on a query with AND and OR conditions Created: 2013-03-06 Updated: 2013-03-12 Resolved: 2013-03-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 5.5.30, 5.3.13 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||
| Description |
|
The following query makes the server crash with a long corrupted stack trace:
Reproducible on maria/5.5 tree starting from revision 3671 (merge 5.3=>5.5), however 5.3 does not crash with the same query. Stack trace (from a debug build, same picture on two different machines, note 2400+ frames):
Reproducible with the default optimizer_switch as well as with all OFF values. |
| Comments |
| Comment by Sergei Golubchik [ 2013-03-07 ] | ||||||||||||||||||||||||||||||||||||
|
What's happening here: In build_equal_items_for_cond() a local copy of cond_equal is created on the stack: 11608 static COND *build_equal_items_for_cond(THD *thd, COND *cond, It contains a List inside. When a List is initialized it does this->last = &this->first; 11662 ((Item_cond_and*)cond)->cond_equal= cond_equal; when this function returns the item gets cond->cond_equal.current_level.last pointer points somewhere in the middle of the stack. Later in Item_equal::merge_into_list(): 5766 if (!merge_into) this *last pointer is written into, which corrupts the stack. | ||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2013-03-08 ] | ||||||||||||||||||||||||||||||||||||
|
This bug manifests itself already in the current build of mariadb 5.3. MariaDB [test]> SELECT * FROM mysql.time_zone
-------------
------------- The expected result is an empty set. The problem is seen for the following simplified query: MariaDB [test]> SELECT * FROM mysql.time_zone WHERE (FALSE OR Time_zone_id = 1) AND Use_leap_seconds <> 'N';
-------------
------------- EXPLAIN EXTENDED for this query returns: MariaDB [test]> EXPLAIN EXTENDED SELECT * FROM mysql.time_zone WHERE (FALSE OR Time_zone_id = 1) AND Use_leap_seconds <> 'N';
---
--- MariaDB [test]> show warnings;
------
------ It can be seen that the WHERE condition has been converted to a condition that isn't equivalent to the original condition. This bug appeared after the patch for mdev-4177 had been pushed into the 5.3 tree (rev 3628). The bug existed before this patch, but bug mdev-4177 | ||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2013-03-08 ] | ||||||||||||||||||||||||||||||||||||
|
The fix has been pushed into the 5.3 tree. |