Skip to content

Commit 14d43f4

Browse files
committed
MDEV-23222 SIGSEG in maria_create() because of double free
The crash happens because a double free in the case CREATE TABLE fails because there is a conflicting tables on disk. Fixed by ensuring that the double free can't happen.
1 parent 4c99e3e commit 14d43f4

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

mysql-test/suite/maria/create.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,16 @@ c1
6262
DROP TABLE t2,t3;
6363
SET @@SQL_MODE=@org_sql_mode;
6464
#
65+
# MDEV-23222 SIGSEGV in maria_status | Assertion `(longlong)
66+
# thd->status_var.local_memory_used >= 0
67+
#
68+
CREATE TABLE t1 (a INT);
69+
INSERT INTO t1 VALUES (1);
70+
CREATE TABLE MDEV_23222 (i INT) DATA DIRECTORY = 'MYSQL_TMP_DIR', ENGINE=Aria TRANSACTIONAL=1;;
71+
flush tables;
72+
CREATE TABLE MDEV_23222 (i INT) DATA DIRECTORY = 'MYSQL_TMP_DIR', ENGINE=Aria TRANSACTIONAL=1;;
73+
Got one of the listed errors
74+
DROP TABLE t1;
75+
#
6576
# End of 10.3 tests
6677
#

mysql-test/suite/maria/create.test

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ SELECT c1 FROM t3 WHERE (c1) IN (SELECT MIN(DISTINCT c1) FROM t2);
7070
DROP TABLE t2,t3;
7171
SET @@SQL_MODE=@org_sql_mode;
7272

73+
--echo #
74+
--echo # MDEV-23222 SIGSEGV in maria_status | Assertion `(longlong)
75+
--echo # thd->status_var.local_memory_used >= 0
76+
--echo #
77+
78+
let $mysqld_datadir= `select @@datadir`;
79+
CREATE TABLE t1 (a INT);
80+
INSERT INTO t1 VALUES (1);
81+
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
82+
--eval CREATE TABLE MDEV_23222 (i INT) DATA DIRECTORY = '$MYSQL_TMP_DIR', ENGINE=Aria TRANSACTIONAL=1;
83+
flush tables;
84+
--remove_file $mysqld_datadir/test/MDEV_23222.frm
85+
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
86+
--error 1,ER_TABLE_EXISTS_ERROR
87+
--eval CREATE TABLE MDEV_23222 (i INT) DATA DIRECTORY = '$MYSQL_TMP_DIR', ENGINE=Aria TRANSACTIONAL=1;
88+
DROP TABLE t1;
89+
--disable_warnings
90+
--remove_file $mysqld_datadir/test/MDEV_23222.MAD
91+
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
92+
--remove_file $MYSQL_TMP_DIR/MDEV_23222.MAD
93+
--enable_warnings
94+
7395
--echo #
7496
--echo # End of 10.3 tests
7597
--echo #

storage/maria/ma_create.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
11631163
FALSE, TRUE))
11641164
goto err;
11651165
my_free(log_data);
1166+
log_data= 0;
11661167
}
11671168

11681169
if (!(flags & HA_DONT_TOUCH_DATA))

0 commit comments

Comments
 (0)