[MDEV-27575] Spider: UBSAN member access within null pointer of type 'struct st_plugin_int and SIGSEGV in intern_plugin_lock on SHUTDOWN when setting Spider as default storage engine (temporary or global) Created: 2022-01-22 Updated: 2023-11-24 Resolved: 2023-11-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Spider |
| Affects Version/s: | 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0 |
| Fix Version/s: | 10.4.33, 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Roel Van de Paar | Assignee: | Yuchen Pei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | affects-tests | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
Leads to:
Only present in the This bug can also be observed, sporadically, with this more generic testcase:
|
| Comments |
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-01-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've confirmed that the bug is reproducible on the preview branch, but it is also reproducible on 10.8 HEAD (e222e44). So, this is not a regression. Further, I think that the server should not allow setting Spider as the default temporary table storage engine because it won't definitely work. cc: Roel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-01-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The server crashes on 10.2-10.8 except 10.3. On 10.3, the server hangs during SHUTDOWN. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-01-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The server raises an error when one tries to set the storage engine which has the HTON_TEMPORARY_NOT_SUPPORTED flag. However, the check is only available on 10.7+ and it is unlikely for users to set Spider as the default tmp SE. So, I will fix the bug on 10.7+ only. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-01-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
holyfoot Please review: https://github.com/MariaDB/server/commit/327ab418e823b1a58eaabe80f2b0233a245794c8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-01-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you nayuta-yanagisawa. Btw, I confirmed that RocksDB does not crash on 10.6.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-01-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hmm. Now, I will see if it is possible to avoid crashes in 10.6 and below. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-01-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Discovered that the testcase above fails on 10.8 with:
However not on 10.6:
Yet this one does not crash (tried a number of times) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-01-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This bug can also be observed, sporadically, with this more generic testcase:
Given this new more generic testcase it may indeed make sense to try and avoid this crash in 10.6 (and earlier) also. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-01-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I have increased the priority given how;
i.e. it would be very hard for any customer running into this to find out the real source for a common setting change. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-02-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I don't know why but --source include/restart_mysqld.inc results in a test failure in the Spider test suites. This makes me difficult to test. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-02-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
nayuta-yanagisawa What is the output? Any relevant logs? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-02-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Roel No output from mysqltest. MTR showed server logs but I found nothing meaningful. The problem will be handled by The Spider hangs on the server startup on 10.4+ ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2022-02-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Likely, not a spider specific problem. Please see if it happens with a different dynamically loaded storage engine | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-03-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
serg Thanks. We already had this discussion (and test) here and also note here. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-03-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Roel I also guess that the crash is not due to Spider. Could you check whether it is reproducible on https://github.com/MariaDB/server/compare/bb-10.2-MDEV-27575? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-03-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
nayuta-yanagisawa The issue does not reproduce in bb-10.2- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-03-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Roel Thank you for your confirmation! I'm not yet sure why it happens only with Spider. I will investigate the reason, but I will not pursue it too deeply since the surrounding code seems to assume that pi could be NULL. serg If you have any idea the reason, I would be grateful for your comments. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2022-03-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Server is shutting down. It needs to unload all plugins. First it tries to unload everything that's possible, Spider cannot be unloaded, because it's referenced by @@global.default_storage_engine. Then server unlocks plugins mentioned by global variables (default_storage_engine, tmp_storage_engine, enforce_storage_engine), sets those variables to NULL, and unloads more plugins that can be unloaded — namely, Spider. You can see the rest in the stack trace — spider_db_done() creates a new THD, new THD needs to lock its default_storage_engine, etc, and it does not expect that the server is almost shut down and default_storage_engine is NULL. I'd say, Spider should not create a new THD that late in the server lifecycle. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-03-08 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you very much for your analysis. The THD creation in spider_db_done() is introduced by the following commit: https://github.com/MariaDB/server/commit/ab9d420df37d76a1ff68e6fd2d5bf53a797c4102 I will try to remove that. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-03-08 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you very much for your analysis++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-04-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The above is not true. HTON_TEMPORARY_NOT_SUPPORTED exists even on 10.2. I misunderstood something. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-06-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
holyfoot https://github.com/MariaDB/server/commit/03935c9bd1f57f6d72b09be4f384bac8bffbe99a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexey Botchkov [ 2022-06-27 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ok to push. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-06-27 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I noticed that the newly added test failed on some buildbots. Checking... http://buildbot.askmonty.org/ci/reports/cross_reference#branch=&revision=03935c9bd1f57f6d72b09be4f384bac8bffbe99a&platform=&fail_name=&fail_variant=&fail_info_full=&typ=&info=&dt=&limit=100&fail_info_short= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-06-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I believe that the failures above are related to problems that lay in Spider's plugin initialization. So, I will resume working on the present issue once | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-08-31 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
During a Spider run, I just noticed that a lot of trials end in this assert (and are thus filtered), so this is blocking testing significantly. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-10-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Please also test with
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2023-05-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
UBSAN also report a member access within null pointer of type 'struct st_plugin_int' in sql/sql_plugin.cc for this:
Leads to:
Same on debug. Confirmed bug present in 10.4 and 11.0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-11-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
An initial patch, based on 10.10. Still need to check for 10.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-11-08 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi holyfoot, ptal thanks (based on 10.10)
There's also a 10.4 version at e3141826794fea9fec771407e8c36feb12cf6f6b, where the SET GLOBAL default_tmp_storage_engine=spider; does not cause an error, presumably because of commit f7216fa63d69448c3de1532a1dd197d0f28faefd which is included in 10.7+ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexey Botchkov [ 2023-11-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ok to push. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-11-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the review. Pushing 9656573376516807b41066dd5f0ff7fa316946fc to 10.4. There's no conflict when cherry-picked to higher versions, but 10.11 |