[MDEV-20261] NULL passed to String::eq, SEGV, server crash, regression in 10.4 Created: 2019-08-05 Updated: 2021-12-11 Resolved: 2020-05-13 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Character Sets, Prepared Statements |
| Affects Version/s: | 10.4 |
| Fix Version/s: | 10.5.4, 10.4.14 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Kris Karas | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | mythtv | ||
| Environment: |
Linux, GCC 9.1, QT 5.12.4, MythTV 30+ |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
On upgrade from MariaDB 10.3 to 10.4, merge_key_fields() calls eq_by_collation(), Item_const_eq() and finally String::eq(NULL, <String>, <charset>), and thus SEGV. MariaDB 10.3 and below are not affected. The bug is reliably reproduced, but hard to narrow down, as the same query will execute twice correctly, and crash the server on the third go. The client in this case is "mythbackend," the server component to the MythTV DVR. It communicates with MariaDB via QT, using prepared statements. The statement that causes the crash is always the same:
The mythbackend program reports the DB error as follows:
As mentioned, this query has been run twice before in the same session, successfully. Immediately prior to the third (and failing) execution is a "smoking gun" of sorts, this log entry in mythbackend's log file:
Immediately afterwards, the SELECT statement is prepared, executed, and crashes. This suggests that the "Close stmt" operation from the immediately preceding prepared statement returned an error. I upgraded QT from 5.12.2 to 5.12.4 (and also MythTV), but the result was the same. I am attaching the MariaDB error.log and general.log showing the SQL executed and the resulting crash. Also attaching the log generated by mythbackend/QT, showing its activity. I recompiled MariaDB with CMAKE_BUILD_TYPE=Debug, and used that with GDB to obtain a more useful backtrace, also attached. |
| Comments |
| Comment by Kris Karas [ 2019-09-12 ] | ||||||||||||||
|
I had hoped that, with the update to 10.4.8, that perhaps this bug would have been fixed (from some other bug report). But the bug remains. I also just tested against 10.4.0, in case the bug was introduced somewhere along the 10.4.x timeline; but it is present in 10.4.0 as well. I have also upgraded to the latest gcc, 9.2.0, as there were reported ABI issues with gcc 9.1.0 (which was used when compiling mariadb 10.4.7). But again, no change. Looks as if I may need to find some way to reproduce this via a script, something that can trivially be run on your side. Due to the complexity of the app, I'm not sure how feasible that will be. Another reasonable tack would be to bisect the code between 10.3.x and 10.4.0 and narrow it down to a particular commit. Any "howto" available for that? I don't have any MariaDB source available locally except for the released tarballs. | ||||||||||||||
| Comment by Elena Stepanova [ 2020-02-05 ] | ||||||||||||||
|
I'm raising the priority because we now have two reports about this (also | ||||||||||||||
| Comment by drew [ 2020-02-10 ] | ||||||||||||||
|
I am also experiencing a similar issue running 10.3.22. Is it possible another commit also is causing the issue?
This issue deadlocks mythtv-backend and possible mythfilldatabase and requires a complete restart/start of maria-db and mythtv and sometimes connected frontends (depending on what they're doing). My query is different however but completely reproducible.
| ||||||||||||||
| Comment by Elena Stepanova [ 2020-02-10 ] | ||||||||||||||
|
It doesn't look like the same problem, not just because it's a different query, but even a different stage. Please attach or paste your server error log. | ||||||||||||||
| Comment by Alexander Barkov [ 2020-05-12 ] | ||||||||||||||
|
This script does not crash:
So these two cases work differenly:
| ||||||||||||||
| Comment by Alexander Barkov [ 2020-05-12 ] | ||||||||||||||
|
This script binding a null SP variable does not crash:
| ||||||||||||||
| Comment by Alexander Barkov [ 2020-05-13 ] | ||||||||||||||
|
| ||||||||||||||
| Comment by Louis Tim Larsen [ 2020-05-22 ] | ||||||||||||||
|
This bug doesn't seem to have been fixed in MariaDB 10.4.13. I still have issues viewing live tv on some channels after upgrading MariaDB on my MythTV backend. When downgrading MariaDB to 10.3.23 it works fine. Also there does not seem to be any reference to this bug in the 10.4.13 release notes: https://mariadb.com/kb/en/mariadb-10413-release-notes/ | ||||||||||||||
| Comment by Elena Stepanova [ 2020-05-22 ] | ||||||||||||||
|
I think that's true, the fix didn't make it to the release and was pushed very soon afterwards. bar, could you please double-check and fix the version accordingly? | ||||||||||||||
| Comment by Louis Tim Larsen [ 2020-06-10 ] | ||||||||||||||
|
This ticket should be reopened as this issue appear unsolved in stable. | ||||||||||||||
| Comment by Alexander Barkov [ 2020-06-11 ] | ||||||||||||||
|
This bug was fixed in 10.4.14. The original fix version 10.4.13 was wrong. i pushed the fix after 10.4.13 was cloned off. | ||||||||||||||
| Comment by Kris Karas [ 2020-08-13 ] | ||||||||||||||
|
This is the OP, just chiming in that the fix from Alexander has been tested (against 10.5.5) and appears to work fine. Today I upgraded 5 instances running 10.4 to 10.5, and figured I'd give it a whirl on the MythTV server still running 10.3.24. Before the fix, reproducing the bug was trivial when changing channels while watching "Live TV" on the MythTV application. After the fix/upgrade, to test, I changed channels with abandon, and could not cause MariaDB to crash. (I did manage to crash the MythTV frontend a few times by asking it to change channels too frequently and to a station with a poor signal, but that's not MariaDB's fault.) Interestingly, I noticed many more connection-aborted errors with 10.5 than with 10.3 during my testing today. The log output from mariadbd was peppered with, for example: | ||||||||||||||
| Comment by Alexander Barkov [ 2020-08-13 ] | ||||||||||||||
|
Hi ktk, thanks for confirming that the bugs has gone. Sorry for the confusion with the initial wrong fixVersion. |