Bug #37740 | Server crashes on execute statement with full text search and match against | ||
---|---|---|---|
Submitted: | 30 Jun 2008 13:25 | Modified: | 7 Aug 2009 0:22 |
Reporter: | Wiktor Kolodziej | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Prepared statements | Severity: | S2 (Serious) |
Version: | 5.0.45, 5.0.51, 4.1, 5.0, 5.1, 6.0 bzr | OS: | Linux (Debian) |
Assigned to: | Anurag Shekhar | CPU Architecture: | Any |
Tags: | against, crash, execute statement, fts, full text search, match |
[30 Jun 2008 13:25]
Wiktor Kolodziej
[30 Jun 2008 14:45]
Sveta Smirnova
Thank you for the report. Verified as described.
[18 May 2009 8: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/74345 2748 Anurag Shekhar 2009-05-18 Bug#37740 Server crashes on execute statement with full text search and match against. While executing a prepared statement server checks the Item_func_match if the table variable is initialized, If it is initialized it assumes that the item_fields too are initialized. And proceeds with execution of prepared statement. But in reality the fields are not initialized, which results in a crash latter when the fields are accessed. This bug is fixed (for 5.0 and 5.1) by setting "table" to 0 so that table and fields are reinitialized while executing the prepared statement. However this fixes only the symptom of the actual problem which is incorrect implementation of Item_func_match::eq(). The fix for 6.0 will be made separately to address the actual problem by fixing implementation in eq() method. @ mysql-test/r/fulltext.result Updated results with the outputs of new test case. @ mysql-test/t/fulltext.test Added new test case to test scenario decribed in the bug. @ sql/item_func.h setting table to 0 to ensure the table and fields are reinitialized while executing the prepared statement.
[21 May 2009 9:06]
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/74681 2750 Anurag Shekhar 2009-05-21 Bug#37740 Server crashes on execute statement with full text search and match against. Server crashes when executing prepared statement with duplicating MATCH() function calls in SELECT and ORDER BY expressions, e.g.: SELECT MATCH(a) AGAINST('test') FROM t1 ORDER BY MATCH(a) AGAINST('test') This query gets optimized by the server, so the value returned by MATCH() from the SELECT list is reused for ORDER BY purposes. To make this optimization server is comparing items from SELECT and ORDER BY lists. We were getting server crash because comparision function for MATCH() item is not intended to be called at this point of execution. In 5.0 and 5.1 this problem is workarounded by resetting MATCH() item to the state as it was during PREPARE. Which in fact means that described above optimization is never applied to MATCH(). In 6.0 correct comparision function will be implemented and duplicating MATCH() items from the ORDER BY list will be optimized. @ mysql-test/r/fulltext.result Updated with the test case for Bug#37740 @ mysql-test/t/fulltext.test A test case for Bug#37740. @ sql/item_func.h Reset 'table' to the state as if Item_func_match was just created. True initialization of 'table' happens in ::fix_fields(). As Item_func_match::eq() may be called before ::fix_fields(), it is expected that 'table' is initialized to 0 when it is reused. This is mostly affecting prepared statements, when the same item doesn't get destroyed, but rather cleaned up and reused.
[21 May 2009 9:31]
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/74682 2750 Anurag Shekhar 2009-05-21 Bug#37740 Server crashes on execute statement with full text search and match against. Server crashes when executing prepared statement with duplicating MATCH() function calls in SELECT and ORDER BY expressions, e.g.: SELECT MATCH(a) AGAINST('test') FROM t1 ORDER BY MATCH(a) AGAINST('test') This query gets optimized by the server, so the value returned by MATCH() from the SELECT list is reused for ORDER BY purposes. To make this optimization server is comparing items from SELECT and ORDER BY lists. We were getting server crash because comparision function for MATCH() item is not intended to be called at this point of execution. In 5.0 and 5.1 this problem is workarounded by resetting MATCH() item to the state as it was during PREPARE. Which in fact means that described above optimization is never applied to MATCH(). In 6.0 correct comparision function will be implemented and duplicating MATCH() items from the ORDER BY list will be optimized. @ mysql-test/r/fulltext.result Updated with the test case for Bug#37740 @ mysql-test/t/fulltext.test A test case for Bug#37740. @ sql/item_func.h Reset 'table' to the state as if Item_func_match was just created. True initialization of 'table' happens in ::fix_fields(). As Item_func_match::eq() may be called before ::fix_fields(), it is expected that 'table' is initialized to 0 when it is reused. This is mostly affecting prepared statements, when the same item doesn't get destroyed, but rather cleaned up and reused.
[15 Jul 2009 9: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/78707 2781 Anurag Shekhar 2009-07-15 Bug#37740 Server crashes on execute statement with full text search and match against. Server crashes when executing prepared statement with duplicating MATCH() function calls in SELECT and ORDER BY expressions, e.g.: SELECT MATCH(a) AGAINST('test') FROM t1 ORDER BY MATCH(a) AGAINST('test') This query gets optimized by the server, so the value returned by MATCH() from the SELECT list is reused for ORDER BY purposes. To make this optimization server is comparing items from SELECT and ORDER BY lists. We were getting server crash because comparision function for MATCH() item is not intended to be called at this point of execution. In 5.0 and 5.1 this problem is workarounded by resetting MATCH() item to the state as it was during PREPARE. In 6.0 correct comparision function will be implemented and duplicating MATCH() items from the ORDER BY list will be optimized. @ mysql-test/r/fulltext.result Updated with the test case for Bug#37740 @ mysql-test/t/fulltext.test A test case for Bug#37740. @ sql/item_func.h True initialization of 'table' happens in ::fix_fields(). As Item_func_match::eq() may be called before ::fix_fields(), it is expected that 'table' is initialized to 0 when it is reused. This is mostly affecting prepared statements, when the same item doesn't get destroyed, but rather cleaned up and reused.
[20 Jul 2009 10:51]
Anurag Shekhar
fix for 5.0 and 5.1 is pushed i will be committing separate patch for 6.0.
[30 Jul 2009 9:32]
Anurag Shekhar
Fix for bug#45130 will fix this bug on 6.0 too.
[4 Aug 2009 13:58]
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:52]
Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090804194615-h40sa098mx4z49qg) (version source revid:ramil@mysql.com-20090715111112-72fdhvyicpo0o9vp) (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 0:22]
Paul DuBois
Noted in 5.0.85, 5.1.38, 5.4.4 changelogs. The server crashed when executing a prepared statement containing a duplicated MATCH() function call in the select list and ORDER BY clause; for example, SELECT MATCH(a) AGAINST('test') FROM t1 ORDER BY MATCH(a) AGAINST('test').
[12 Aug 2009 22:53]
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 2:10]
Paul DuBois
Ignore previous comment about 5.4.2.
[1 Oct 2009 5:58]
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)
[8 Oct 2009 20:13]
Paul DuBois
The 5.4 fix has been pushed to 5.4.2.