[MDEV-28124] Server crashes in Explain_aggr_filesort::print_json_members upon SHOW ANALYZE/EXPLAIN FORMAT=JSON Created: 2022-03-18 Updated: 2022-05-02 Resolved: 2022-04-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | N/A |
| Fix Version/s: | 10.9.1 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Elena Stepanova | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
The test case is for reproducing/debugging only, don't put it into the regression suite! The test case is obviously non-deterministic. If it doesn't fail for you right away, try to adjust run and show values.
Also reproducible with SHOW ANALYZE FORMAT=JSON |
| Comments |
| Comment by Sergei Petrunia [ 2022-03-21 ] | ||||||||||||||||
|
Reproducible for me. Indeed, item seems to point to free'd memory:
| ||||||||||||||||
| Comment by Sergei Petrunia [ 2022-03-21 ] | ||||||||||||||||
|
It crashes here:
log_slow_statement is where --log_slow_verbosity=explain prints tabular ANALYZE output. Tabular output is "self-contained" (it checks if the attached conditions are NULL but does not print them). For JSON output, one needs to access items to print the conditions. Could it be that the cut-off for printing the conditions is at some earlier stage in the query processing? | ||||||||||||||||
| Comment by Sergei Petrunia [ 2022-03-21 ] | ||||||||||||||||
|
Items are freed in free_items()... Looking at the code:
Indeed, it seems like it's possible to try producing EXPLAIN FORMAT=JSON output after free_items() has been called. | ||||||||||||||||
| Comment by Sergei Petrunia [ 2022-03-21 ] | ||||||||||||||||
|
First fix suggestion: disallow producing EXPLAIN FORMAT=JSON output before making the thd->cleanup_after_query() call. | ||||||||||||||||
| Comment by Sergei Petrunia [ 2022-03-21 ] | ||||||||||||||||
|
https://gist.github.com/spetrunia/3e2fa7081caf2a13f843e9fa5f93103b - If I apply this, I start getting a different kind of crash: https://gist.github.com/spetrunia/d3342301e28b89096e12e853d024de8c . I've encountered something similar to this for ANALYZE. Check out comments for the Item_temptable_field. Note there:
is this true anymore? | ||||||||||||||||
| Comment by Sergei Petrunia [ 2022-03-22 ] | ||||||||||||||||
|
This is where the Field object gets freed:
Note that the table is freed in free_tmp_table(), that is, it's a temporary table.
| ||||||||||||||||
| Comment by Sergei Petrunia [ 2022-03-22 ] | ||||||||||||||||
|
Fix candidate : https://gist.github.com/spetrunia/211ae821160d5ecdbb403609d536f538 . It also fixes | ||||||||||||||||
| Comment by Sergei Petrunia [ 2022-04-12 ] | ||||||||||||||||
|
Fix pushed into preview-10.9- | ||||||||||||||||
| Comment by Marko Mäkelä [ 2022-05-02 ] | ||||||||||||||||
|
Because the sys schema depends on PLUGIN_PERFSCHEMA,
should have been included in the tests. |