[MDEV-6323] ‘explain_node’ may be used uninitialized in this function Created: 2014-06-10 Updated: 2015-02-25 Resolved: 2015-02-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0.11 |
| Fix Version/s: | 10.1.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergey Vojtovich | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | explain, optimizer | ||
| Issue Links: |
|
||||||||
| Description |
|
Compiling MariaDB with ASAN gives:
Please check if there is a real bug here. |
| Comments |
| Comment by Sergei Petrunia [ 2015-02-19 ] | |||||||||||||||||
|
Looking at where explain_node may be uninitialized.
and removed the corresponding else-branch. This is useful but doesn't fix the warning. | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-19 ] | |||||||||||||||||
|
Fixing the warning requires figuring what to do when this else-if branch is not taken:
| |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-19 ] | |||||||||||||||||
|
Trying to find when this tescase fails.. the following testcase crashes the ASAN build, but not the regular debug build:
... and it's not clear why the regular build doesn't crash. They seem to be taking different execution path when they are optimized. | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-19 ] | |||||||||||||||||
|
... No, the crash goes away with the latest tree. The warning is still there. | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-20 ] | |||||||||||||||||
|
Getting back to the question of what are the cases where this else-if branch is not taken:
Running mtr yielded this example:
JOIN::optimize and JOIN::save_explain_data_intern are invoked for the view (it has select_lex->select_number=2). | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-20 ] | |||||||||||||||||
|
It happens here:
Going up, we see that select_describe() calls mysql_explain_union for the VIEW here:
I think we should not try to run JOIN::optimize() on a VIEW that has been merged. I suppose, it is important that the statement is INSERT ... SELECT. This is a case of special kind of VIEW merging. Need to discuss this with sanja. | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-20 ] | |||||||||||||||||
|
Btw, the problem is only with EXPLAIN, the statement
does not call JOIN::optimize for the VIEW's select. | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-24 ] | |||||||||||||||||
|
How to tell if this is a derived table that's "merged for INSERT":
| |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-25 ] | |||||||||||||||||
|
Developed a fix, against 10.0 tree. I am hesitant to push it into 10.0, though, as the fix doesn't fix any user-visible effect. It only makes the compiler warning go away, and makes the code cleaner. Interestingly, 10.1 has the same code, but ASAN doesn't produce the warning there. It doesn't produce it even if I take the g++ command line from 10.0 and compile sql_select.cc in 10.1 with it. Instead, it produces warnings in LooseScan code (which is most likely the same between 10.0 and 10.1, too. And I dont get the warnings in LooseScan code in 10.0). | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-25 ] | |||||||||||||||||
|
Considering the above, I will still push the fix into 10.1 but not into 10.0 |