[MDEV-31102] Crash when pushing condition into view defined as union Created: 2023-04-21 Updated: 2023-05-25 Resolved: 2023-04-24 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.4, 10.5, 10.6 |
| Fix Version/s: | 10.11.3, 11.0.2, 10.4.29, 10.5.20, 10.6.13, 10.8.8, 10.9.6, 10.10.4 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Igor Babaev | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||
| Description |
|
This test case cases a crash of the server:
|
| Comments |
| Comment by Igor Babaev [ 2023-04-21 ] | ||||||||||||||||||||||||||||||||
|
The following patch fixes the problem:
| ||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2023-04-21 ] | ||||||||||||||||||||||||||||||||
|
This bug was introduced with the commit
The patch added the class Item_direct_ref_to_item with such implementation of virtual methods get_copy() and build_clone()
As a result whenever we use an object of the type Item_direct_ref_to_item r within an expression and for this expression build_clone() is called the sub-item starting with r is not actually cloned as it shares items it refers to with the cloned expression. When the clone is cleaned up the shared items of the original expression are also cleaned up. After this any traversal of the original expression may cause a crash. In the above test case the crash happened at an attempt to traverse the original cloned item when calling SELECT_LEX::update_used_tables(). | ||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2023-04-21 ] | ||||||||||||||||||||||||||||||||
|
Note that objects of the type Item_direct_ref_to_item in the current code can appear only at the first execution of prepared statement. They never appear if the query is executed directly. | ||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-04-21 ] | ||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-04-24 ] | ||||||||||||||||||||||||||||||||
|
60c1b15 is ok to push | ||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2023-04-24 ] | ||||||||||||||||||||||||||||||||
|
A fix for this bug was pushed into 10.4. The fix should be merged upstream as it is. |