[MDEV-32395] update_depend_map_for_order: SEGV at /mariadb-11.3.0/sql/sql_select.cc:16583 Created: 2023-10-10 Updated: 2024-02-08 |
|
| Status: | In Review |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Server |
| Affects Version/s: | 11.3.0 |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Xin Wen | Assignee: | Igor Babaev |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 20.04 |
||
| Issue Links: |
|
||||
| Description |
|
Run these queries in release build: CREATE TABLE t0 ( c6 INT , c21 INT ) ; Will trigger Segmentation fault. #0 0x0000000000c24454 in update_depend_map_for_order (join=0x6290000b7480, order=0x6290000b46c0) at /home/wx/mariadb-11.3.0/sql/sql_select.cc:16583 |
| Comments |
| Comment by Alice Sherepa [ 2023-10-12 ] | |||||||||||||||||||||||||||||||
|
Thanks! THis is the same as MDEV-29681
| |||||||||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-11-04 ] | |||||||||||||||||||||||||||||||
|
MDEV-29681 is a different case, reopening this issue.
| |||||||||||||||||||||||||||||||
| Comment by Jason (Inactive) [ 2023-11-14 ] | |||||||||||||||||||||||||||||||
|
simplified query to this: WITH t0(c6) AS (VALUES(0)), Of note is that the columns in the subquery (c42) refer to the outer query (t0.c6). | |||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-11-15 ] | |||||||||||||||||||||||||||||||
|
As pointed out by Jason in the email, one of the steps that creates the problem (and I suspect it's the main one) in that eliminate_item_equal() "unwraps" Item_direct_ref objects:
The remove_item_direct_ref() was introduced by https://github.com/MariaDB/server/commit/ae15f91f227015b3e1ad3f566db9396232cf0a3f
unfortunately, that patch doesn't describe the purpose of remove_item_direct_ref() call. Also note that disabling condition pushdown and running the above Jason's simplified query still causes the crash. | |||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-11-15 ] | |||||||||||||||||||||||||||||||
|
... as for HAVING->WHERE pushdown: it looks like it could happen for the subquery:
but the code doesn't do it: collect_grouping_fields disallows Item_direct_ref objects (no idea why). | |||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2023-11-15 ] | |||||||||||||||||||||||||||||||
|
The following test case that does not use any CTE or derived tables and does not use any condition pushdown crashes in the same way on the latest 10.4:
| |||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2023-11-16 ] | |||||||||||||||||||||||||||||||
|
It looks like the following change fixes the problem:
| |||||||||||||||||||||||||||||||
| Comment by Jason (Inactive) [ 2023-11-17 ] | |||||||||||||||||||||||||||||||
|
Igor's suggested patch does seem to resolve the problem, and it passes my local run of the main tests including those introduced by https://github.com/MariaDB/server/commit/ae15f91f227015b3e1ad3f566db9396232cf0a3f (which introduced the change). I will submit it to buildbot as soon as I can resolve some permission issues with the remote repo (working through helpdesk). It's still unclear why remove_item_direct_ref() was introduced in the above code in the first place, but removing them apparently does no harm to existing tests and resolves the issue reported here. | |||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-11-21 ] | |||||||||||||||||||||||||||||||
|
Note: eliminate_item_equal() is the only place that has calls to {remove_item_direct_ref() . If we make it not to call remove_item_direct_ref, let's then remove remove_item_direct_ref altogether? | |||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-11-29 ] | |||||||||||||||||||||||||||||||
Re-assigning to Igor as he has reviewed the patch that introduced that call. | |||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2024-02-08 ] | |||||||||||||||||||||||||||||||
|
igor the pull request https://github.com/MariaDB/server/pull/2873 has been waiting a while now since jasoncu left. |