Skip to content

Commit

Permalink
MDEV-29002 Spider: remove SPIDER_CONN::loop_check_meraged_last
Browse files Browse the repository at this point in the history
The field is assigned but unused, and it causes heap-use-after-free.
  • Loading branch information
mariadb-YuchenPei committed Jan 11, 2024
1 parent 761d5c8 commit 7801c6d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 7 deletions.
34 changes: 34 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_29002.result
@@ -0,0 +1,34 @@
for master_1
for child2
for child3
SET spider_same_server_link= on;
CREATE SERVER s FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (a INT);
CREATE TABLE t1_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'";
CREATE TABLE t2_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'";
SELECT * FROM t1_spider, t2_spider;
a a
SELECT table_name, index_name, cardinality FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name IN ('t1_spider','t2_spider');
table_name index_name cardinality
RENAME TABLE t1_spider TO t3_spider;
SELECT * FROM t3_spider;
a
DROP TABLE t3_spider, t2_spider, t;
drop server s;
CREATE TABLE t1 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
CREATE TABLE t3 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
SHOW TABLE STATUS;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0
t2 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0
t3 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0
Warnings:
Warning 1429 Unable to connect to foreign data source: srv
Warning 1429 Unable to connect to foreign data source: srv
Warning 1429 Unable to connect to foreign data source: srv
drop table t1, t2, t3;
for master_1
for child2
for child3
32 changes: 32 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_29002.test
@@ -0,0 +1,32 @@
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
SET spider_same_server_link= on;
evalp CREATE SERVER s FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

CREATE TABLE t (a INT);
CREATE TABLE t1_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'";
CREATE TABLE t2_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'";
SELECT * FROM t1_spider, t2_spider;
SELECT table_name, index_name, cardinality FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name IN ('t1_spider','t2_spider');
RENAME TABLE t1_spider TO t3_spider;
SELECT * FROM t3_spider;

DROP TABLE t3_spider, t2_spider, t;
drop server s;

# case by roel
CREATE TABLE t1 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
CREATE TABLE t3 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
SHOW TABLE STATUS;
drop table t1, t2, t3;

--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
6 changes: 0 additions & 6 deletions storage/spider/spd_conn.cc
Expand Up @@ -1783,13 +1783,7 @@ int spider_conn_queue_and_merge_loop_check(
lcptr->flag = SPIDER_LOP_CHK_MERAGED;
lcptr->next = NULL;
if (!conn->loop_check_meraged_first)
{
conn->loop_check_meraged_first = lcptr;
conn->loop_check_meraged_last = lcptr;
} else {
conn->loop_check_meraged_last->next = lcptr;
conn->loop_check_meraged_last = lcptr;
}
}
DBUG_RETURN(0);

Expand Down
1 change: 0 additions & 1 deletion storage/spider/spd_include.h
Expand Up @@ -940,7 +940,6 @@ typedef struct st_spider_conn
SPIDER_CONN_LOOP_CHECK *loop_check_ignored_first;
SPIDER_CONN_LOOP_CHECK *loop_check_ignored_last;
SPIDER_CONN_LOOP_CHECK *loop_check_meraged_first;
SPIDER_CONN_LOOP_CHECK *loop_check_meraged_last;
} SPIDER_CONN;

typedef struct st_spider_lgtm_tblhnd_share
Expand Down

0 comments on commit 7801c6d

Please sign in to comment.