Skip to content

Commit e7208bd

Browse files
MDEV-26158 SIGSEGV in spider_free_mem from ha_spider::open on INSERT
The server crashes due to passing NULL to spider_free(). In some cases, this == pt_handler_share_handlers[0] at the label error_get_share in ha_spider::open(). In such cases, to nullify pt_handler_share_handlers[0]->wide_handler is nothing but to nullify this->wide_handler. We should not do this before freeing this->wide_handler.
1 parent edde908 commit e7208bd

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

storage/spider/ha_spider.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,13 @@ int ha_spider::open(
659659
error_get_share:
660660
if (wide_handler_alloc)
661661
{
662+
spider_free(spider_current_trx, wide_handler, MYF(0));
662663
#ifdef WITH_PARTITION_STORAGE_ENGINE
663664
if (pt_handler_share_handlers)
664665
{
665666
pt_handler_share_handlers[0]->wide_handler = NULL;
666667
}
667668
#endif
668-
spider_free(spider_current_trx, wide_handler, MYF(0));
669669
spider->wide_handler = NULL;
670670
owner->wide_handler = NULL;
671671
owner->wide_handler_owner = FALSE;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# MDEV-26158 SIGSEGV in spider_free_mem from ha_spider::open on INSERT
3+
#
4+
for master_1
5+
for child2
6+
child2_1
7+
child2_2
8+
child2_3
9+
for child3
10+
connection master_1;
11+
CREATE DATABASE auto_test_local;
12+
USE auto_test_local;
13+
CREATE TABLE t (
14+
c INT
15+
) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a"'
16+
PARTITION BY LIST COLUMNS(`c`) (
17+
PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"'
18+
);
19+
INSERT INTO t SELECT * FROM t;
20+
ERROR 42000: Unknown database 'auto_test_remote'
21+
DROP DATABASE auto_test_local;
22+
for master_1
23+
for child2
24+
child2_1
25+
child2_2
26+
child2_3
27+
for child3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!include include/default_mysqld.cnf
2+
!include ../my_1_1.cnf
3+
!include ../my_2_1.cnf
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--echo #
2+
--echo # MDEV-26158 SIGSEGV in spider_free_mem from ha_spider::open on INSERT
3+
--echo #
4+
5+
--disable_query_log
6+
--disable_result_log
7+
--source ../../t/test_init.inc
8+
--enable_result_log
9+
--enable_query_log
10+
11+
--connection master_1
12+
CREATE DATABASE auto_test_local;
13+
USE auto_test_local;
14+
15+
eval CREATE TABLE t (
16+
c INT
17+
) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a"'
18+
PARTITION BY LIST COLUMNS(`c`) (
19+
PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"'
20+
);
21+
22+
--error ER_BAD_DB_ERROR
23+
INSERT INTO t SELECT * FROM t;
24+
25+
DROP DATABASE auto_test_local;
26+
27+
--disable_query_log
28+
--disable_result_log
29+
--source ../../t/test_deinit.inc
30+
--enable_result_log
31+
--enable_query_log

0 commit comments

Comments
 (0)