Commit 0253a2f4 authored by Yuchen Pei's avatar Yuchen Pei Committed by Jan Lindström

MDEV-26541 Make UBSAN builds work with spider again.

When built with ubsan and trying to load the spider plugin, the hidden
visibility of mysqld compiling flag causes ha_spider.so to be missing
the symbol ha_partition. This commit fixes that, as well as some
memcpy null pointer issues when built with ubsan.
Signed-off-by: default avatarYuchen Pei <yuchen.pei@mariadb.com>
parent a27b8b26
...@@ -197,6 +197,15 @@ FOREACH(se aria partition perfschema sql_sequence wsrep) ...@@ -197,6 +197,15 @@ FOREACH(se aria partition perfschema sql_sequence wsrep)
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
IF(VISIBILITY_HIDDEN_FLAG AND TARGET partition AND WITH_UBSAN)
# the spider plugin needs some partition symbols from inside mysqld
# when built with ubsan, in which case we need to remove
# -fvisibility=hidden from partition
GET_TARGET_PROPERTY(f partition COMPILE_FLAGS)
STRING(REPLACE "${VISIBILITY_HIDDEN_FLAG}" "" f ${f})
SET_TARGET_PROPERTIES(partition PROPERTIES COMPILE_FLAGS "${f}")
ENDIF()
IF(WIN32) IF(WIN32)
SET(MYSQLD_SOURCE main.cc nt_servc.cc message.rc) SET(MYSQLD_SOURCE main.cc nt_servc.cc message.rc)
TARGET_LINK_LIBRARIES(sql psapi) TARGET_LINK_LIBRARIES(sql psapi)
......
#
# MDEV-26541 Undefined symbol: _ZTI12ha_partition when attempting to use ha_spider.so in UBSAN builds
#
INSTALL PLUGIN spider SONAME 'ha_spider.so';
DROP FUNCTION spider_flush_table_mon_cache;
DROP FUNCTION spider_copy_tables;
DROP FUNCTION spider_ping_table;
DROP FUNCTION spider_bg_direct_sql;
DROP FUNCTION spider_direct_sql;
UNINSTALL PLUGIN spider_alloc_mem;
UNINSTALL PLUGIN spider;
DROP TABLE IF EXISTS mysql.spider_xa;
DROP TABLE IF EXISTS mysql.spider_xa_member;
DROP TABLE IF EXISTS mysql.spider_xa_failed_log;
DROP TABLE IF EXISTS mysql.spider_tables;
DROP TABLE IF EXISTS mysql.spider_link_mon_servers;
DROP TABLE IF EXISTS mysql.spider_link_failed_log;
DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery;
DROP TABLE IF EXISTS mysql.spider_table_sts;
DROP TABLE IF EXISTS mysql.spider_table_crd;
--echo #
--echo # MDEV-26541 Undefined symbol: _ZTI12ha_partition when attempting to use ha_spider.so in UBSAN builds
--echo #
if (`select not(count(*)) from information_schema.system_variables where variable_name='have_sanitizer' and global_value="UBSAN"`)
{
--skip test needs to be run with UBSAN
}
# init spider
INSTALL PLUGIN spider SONAME 'ha_spider.so';
let $PLUGIN_NAME= spider_flush_table_mon_cache;
let $PLUGIN_EXIST=
`SELECT COUNT(*) FROM mysql.func WHERE name = '$PLUGIN_NAME'`;
while (!$PLUGIN_EXIST)
{
let $PLUGIN_EXIST=
`SELECT COUNT(*) FROM mysql.func WHERE name = '$PLUGIN_NAME'`;
}
# deinit spider
DROP FUNCTION spider_flush_table_mon_cache;
DROP FUNCTION spider_copy_tables;
DROP FUNCTION spider_ping_table;
DROP FUNCTION spider_bg_direct_sql;
DROP FUNCTION spider_direct_sql;
UNINSTALL PLUGIN spider_alloc_mem;
UNINSTALL PLUGIN spider;
DROP TABLE IF EXISTS mysql.spider_xa;
DROP TABLE IF EXISTS mysql.spider_xa_member;
DROP TABLE IF EXISTS mysql.spider_xa_failed_log;
DROP TABLE IF EXISTS mysql.spider_tables;
DROP TABLE IF EXISTS mysql.spider_link_mon_servers;
DROP TABLE IF EXISTS mysql.spider_link_failed_log;
DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery;
DROP TABLE IF EXISTS mysql.spider_table_sts;
DROP TABLE IF EXISTS mysql.spider_table_crd;
...@@ -518,18 +518,25 @@ SPIDER_CONN *spider_create_conn( ...@@ -518,18 +518,25 @@ SPIDER_CONN *spider_create_conn(
conn->tgt_host = tmp_host; conn->tgt_host = tmp_host;
memcpy(conn->tgt_host, share->tgt_hosts[link_idx], memcpy(conn->tgt_host, share->tgt_hosts[link_idx],
share->tgt_hosts_lengths[link_idx]); share->tgt_hosts_lengths[link_idx]);
conn->tgt_username_length = share->tgt_usernames_lengths[link_idx]; conn->tgt_username_length = share->tgt_usernames_lengths[link_idx];
conn->tgt_username = tmp_username; conn->tgt_username = tmp_username;
memcpy(conn->tgt_username, share->tgt_usernames[link_idx], if (conn->tgt_username_length)
share->tgt_usernames_lengths[link_idx]); memcpy(conn->tgt_username, share->tgt_usernames[link_idx],
share->tgt_usernames_lengths[link_idx]);
conn->tgt_password_length = share->tgt_passwords_lengths[link_idx]; conn->tgt_password_length = share->tgt_passwords_lengths[link_idx];
conn->tgt_password = tmp_password; conn->tgt_password = tmp_password;
memcpy(conn->tgt_password, share->tgt_passwords[link_idx], if (conn->tgt_password_length)
share->tgt_passwords_lengths[link_idx]); memcpy(conn->tgt_password, share->tgt_passwords[link_idx],
share->tgt_passwords_lengths[link_idx]);
conn->tgt_socket_length = share->tgt_sockets_lengths[link_idx]; conn->tgt_socket_length = share->tgt_sockets_lengths[link_idx];
conn->tgt_socket = tmp_socket; conn->tgt_socket = tmp_socket;
memcpy(conn->tgt_socket, share->tgt_sockets[link_idx], if (conn->tgt_socket_length)
share->tgt_sockets_lengths[link_idx]); memcpy(conn->tgt_socket, share->tgt_sockets[link_idx],
share->tgt_sockets_lengths[link_idx]);
conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx]; conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx];
conn->tgt_wrapper = tmp_wrapper; conn->tgt_wrapper = tmp_wrapper;
memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx],
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment