|
| 1 | +--echo # |
| 2 | +--echo # MDEV-34849 SIGSEGV in server_mysql_real_connect, spider_db_connect, __strcmp_evex and __strnlen_evex, ASAN heap-use-after-free in spider_db_connect on INSERT |
| 3 | +--echo # |
| 4 | + |
| 5 | +INSTALL SONAME 'ha_spider'; |
| 6 | + |
| 7 | +CREATE TABLE t1 (c INT) ENGINE=Spider; |
| 8 | +CREATE TABLE t2 (c INT) ENGINE=Spider; |
| 9 | + |
| 10 | +# So that t2 is inserted into spider_init_error_tables and in INSERT |
| 11 | +# INTO t2 we go into failure mode in spider_get_share() |
| 12 | +--error 1429 |
| 13 | +SELECT * FROM t2; |
| 14 | + |
| 15 | +# Resets the table cache so that the next two queries will call |
| 16 | +# ha_spider::open() on t1 and t2 respectively |
| 17 | +set @old_table_open_cache=@@global.table_open_cache; |
| 18 | +SET GLOBAL table_open_cache=0; |
| 19 | + |
| 20 | +# This causes trx_ha->wait_for_reusing to remain false during the |
| 21 | +# (non-)rollback at the end of the first INSERT INTO t1 statement, so |
| 22 | +# that the second INSERT INTO t1 enters the branch in |
| 23 | +# spider_check_trx_and_get_conn() that does not update spider fields |
| 24 | +# including NULLing its associated connections. |
| 25 | +set autocommit=0; |
| 26 | + |
| 27 | +# Misses the table cache when opening the table. Spider then opens the |
| 28 | +# table so that the next INSERT INTO t1 causes a table cache hit and |
| 29 | +# skips the call to open table with spider |
| 30 | +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE |
| 31 | +/* 1 */ INSERT INTO t1 VALUES (0); |
| 32 | + |
| 33 | +# Spider opens the table and creates a t2 share, assigns it to |
| 34 | +# conn->queued_connect_share, and frees the t2 share on failure |
| 35 | +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE |
| 36 | +/* 2 */ INSERT INTO t2 VALUES (0); |
| 37 | + |
| 38 | +# So that the final INSERT INTO t1 will decide not to return the same |
| 39 | +# error in spider_db_connect(), and move onto using the freed share |
| 40 | +set global spider_connect_error_interval=0; |
| 41 | + |
| 42 | +# Skips call to ha_spider::open(), so it does not create a t1 share |
| 43 | +# nor reassign it to conn->queued_connect_share, causing it to remain |
| 44 | +# the freed t2 share, and using the share results in segv |
| 45 | +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE |
| 46 | +/* 3 */ INSERT INTO t1 VALUES (0); |
| 47 | + |
| 48 | +drop table t1, t2; |
| 49 | + |
| 50 | +set global table_open_cache=@old_table_open_cache; |
| 51 | +--disable_query_log |
| 52 | +--source ../../include/clean_up_spider.inc |
0 commit comments