[MDEV-24910] Crash with SELECT that uses table value constructor as a subselect Created: 2021-02-18 Updated: 2021-03-02 Resolved: 2021-02-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.3.27 |
| Fix Version/s: | 10.3.29, 10.4.19, 10.5.10 |
| Type: | Bug | Priority: | Major |
| Reporter: | Igor Babaev | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
The following test case causes a crash of the server in 10.3
|
| Comments |
| Comment by Igor Babaev [ 2021-02-18 ] | ||||||||||||||||||||||||||||||||||
|
Most probably the bug affects also 10.4,10.5. | ||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-02-18 ] | ||||||||||||||||||||||||||||||||||
|
The following query
causes a crash of the server of the same kind: the states of the stack are quite similar | ||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-02-18 ] | ||||||||||||||||||||||||||||||||||
|
Let's look how the query
is processed. | ||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-02-18 ] | ||||||||||||||||||||||||||||||||||
|
If to substitute the above mentioned call of the exclude method for the call of the exclude_from_tree method that does does not destroy the slave structure the failing queries return correct result sets:
Yet if we look at the output of the EXPLAIN for the query
we see that it lacks any lines related to the scan of the table t1
although the query itself returns the right result set:
Valgrind does not report any problems either for all queries considered above or for explains for them. | ||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-02-18 ] | ||||||||||||||||||||||||||||||||||
|
Another test case where the query returns the right result set, yet leads a memory leek
Valgrind reports the following for the above above test:
| ||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-02-18 ] | ||||||||||||||||||||||||||||||||||
|
Debugging shows that the mem-root allocated for the temporary table to store the rows of v1 is never freed. It happens because the cleanup method for the unit
However after the call we have
It means that the unit is lost in the select tree. | ||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-02-18 ] | ||||||||||||||||||||||||||||||||||
|
All above observations forces us to re-engineer the code of the function wrap_tvc(). | ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2021-02-22 ] | ||||||||||||||||||||||||||||||||||
|
f3eafa5e05c924bfcf152a3200009d3f3c5819fc OK to push | ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2021-02-25 ] | ||||||||||||||||||||||||||||||||||
|
OK | ||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-02-25 ] | ||||||||||||||||||||||||||||||||||
|
The problem with EXPLAIN has nothing to do with this bug and | ||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-02-25 ] | ||||||||||||||||||||||||||||||||||
|
A fix for this bug was pushed into 10.3. |