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)
ENDIF()
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)
SET(MYSQLD_SOURCE main.cc nt_servc.cc message.rc)
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(
conn->tgt_host = tmp_host;
memcpy(conn->tgt_host, share->tgt_hosts[link_idx],
share->tgt_hosts_lengths[link_idx]);
conn->tgt_username_length = share->tgt_usernames_lengths[link_idx];
conn->tgt_username = tmp_username;
memcpy(conn->tgt_username, share->tgt_usernames[link_idx],
share->tgt_usernames_lengths[link_idx]);
if (conn->tgt_username_length)
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 = tmp_password;
memcpy(conn->tgt_password, share->tgt_passwords[link_idx],
share->tgt_passwords_lengths[link_idx]);
if (conn->tgt_password_length)
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 = tmp_socket;
memcpy(conn->tgt_socket, share->tgt_sockets[link_idx],
share->tgt_sockets_lengths[link_idx]);
if (conn->tgt_socket_length)
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 = tmp_wrapper;
memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx],
......
......@@ -682,112 +682,144 @@ int spider_create_trx_alter_table(
alter_table->tmp_tgt_default_groups_lengths = tmp_tgt_default_groups_lengths;
alter_table->tmp_static_link_ids_lengths = tmp_static_link_ids_lengths;
size_t len;
for(roop_count = 0; roop_count < (int) share->all_link_count; roop_count++)
{
tmp_server_names[roop_count] = tmp_server_names_char;
memcpy(tmp_server_names_char,
share_alter->tmp_server_names[roop_count],
sizeof(char) * share_alter->tmp_server_names_lengths[roop_count]);
tmp_server_names_char +=
share_alter->tmp_server_names_lengths[roop_count] + 1;
tmp_tgt_table_names[roop_count] = tmp_tgt_table_names_char;
memcpy(tmp_tgt_table_names_char,
share_alter->tmp_tgt_table_names[roop_count],
sizeof(char) * share_alter->tmp_tgt_table_names_lengths[roop_count]);
tmp_tgt_table_names_char +=
share_alter->tmp_tgt_table_names_lengths[roop_count] + 1;
tmp_tgt_dbs[roop_count] = tmp_tgt_dbs_char;
memcpy(tmp_tgt_dbs_char, share_alter->tmp_tgt_dbs[roop_count],
sizeof(char) * share_alter->tmp_tgt_dbs_lengths[roop_count]);
tmp_tgt_dbs_char +=
share_alter->tmp_tgt_dbs_lengths[roop_count] + 1;
tmp_tgt_hosts[roop_count] = tmp_tgt_hosts_char;
memcpy(tmp_tgt_hosts_char, share_alter->tmp_tgt_hosts[roop_count],
sizeof(char) * share_alter->tmp_tgt_hosts_lengths[roop_count]);
tmp_tgt_hosts_char +=
share_alter->tmp_tgt_hosts_lengths[roop_count] + 1;
tmp_tgt_usernames[roop_count] = tmp_tgt_usernames_char;
memcpy(tmp_tgt_usernames_char, share_alter->tmp_tgt_usernames[roop_count],
sizeof(char) * share_alter->tmp_tgt_usernames_lengths[roop_count]);
tmp_tgt_usernames_char +=
share_alter->tmp_tgt_usernames_lengths[roop_count] + 1;
tmp_tgt_passwords[roop_count] = tmp_tgt_passwords_char;
memcpy(tmp_tgt_passwords_char, share_alter->tmp_tgt_passwords[roop_count],
sizeof(char) * share_alter->tmp_tgt_passwords_lengths[roop_count]);
tmp_tgt_passwords_char +=
share_alter->tmp_tgt_passwords_lengths[roop_count] + 1;
tmp_tgt_sockets[roop_count] = tmp_tgt_sockets_char;
memcpy(tmp_tgt_sockets_char, share_alter->tmp_tgt_sockets[roop_count],
sizeof(char) * share_alter->tmp_tgt_sockets_lengths[roop_count]);
tmp_tgt_sockets_char +=
share_alter->tmp_tgt_sockets_lengths[roop_count] + 1;
tmp_tgt_wrappers[roop_count] = tmp_tgt_wrappers_char;
memcpy(tmp_tgt_wrappers_char, share_alter->tmp_tgt_wrappers[roop_count],
sizeof(char) * share_alter->tmp_tgt_wrappers_lengths[roop_count]);
tmp_tgt_wrappers_char +=
share_alter->tmp_tgt_wrappers_lengths[roop_count] + 1;
tmp_tgt_ssl_cas[roop_count] = tmp_tgt_ssl_cas_char;
memcpy(tmp_tgt_ssl_cas_char, share_alter->tmp_tgt_ssl_cas[roop_count],
sizeof(char) * share_alter->tmp_tgt_ssl_cas_lengths[roop_count]);
tmp_tgt_ssl_cas_char +=
share_alter->tmp_tgt_ssl_cas_lengths[roop_count] + 1;
tmp_tgt_ssl_capaths[roop_count] = tmp_tgt_ssl_capaths_char;
memcpy(tmp_tgt_ssl_capaths_char,
share_alter->tmp_tgt_ssl_capaths[roop_count],
sizeof(char) * share_alter->tmp_tgt_ssl_capaths_lengths[roop_count]);
tmp_tgt_ssl_capaths_char +=
share_alter->tmp_tgt_ssl_capaths_lengths[roop_count] + 1;
tmp_tgt_ssl_certs[roop_count] = tmp_tgt_ssl_certs_char;
memcpy(tmp_tgt_ssl_certs_char, share_alter->tmp_tgt_ssl_certs[roop_count],
sizeof(char) * share_alter->tmp_tgt_ssl_certs_lengths[roop_count]);
tmp_tgt_ssl_certs_char +=
share_alter->tmp_tgt_ssl_certs_lengths[roop_count] + 1;
tmp_tgt_ssl_ciphers[roop_count] = tmp_tgt_ssl_ciphers_char;
memcpy(tmp_tgt_ssl_ciphers_char,
share_alter->tmp_tgt_ssl_ciphers[roop_count],
sizeof(char) * share_alter->tmp_tgt_ssl_ciphers_lengths[roop_count]);
tmp_tgt_ssl_ciphers_char +=
share_alter->tmp_tgt_ssl_ciphers_lengths[roop_count] + 1;
tmp_tgt_ssl_keys[roop_count] = tmp_tgt_ssl_keys_char;
memcpy(tmp_tgt_ssl_keys_char, share_alter->tmp_tgt_ssl_keys[roop_count],
sizeof(char) * share_alter->tmp_tgt_ssl_keys_lengths[roop_count]);
tmp_tgt_ssl_keys_char +=
share_alter->tmp_tgt_ssl_keys_lengths[roop_count] + 1;
tmp_tgt_default_files[roop_count] = tmp_tgt_default_files_char;
memcpy(tmp_tgt_default_files_char,
share_alter->tmp_tgt_default_files[roop_count],
sizeof(char) * share_alter->tmp_tgt_default_files_lengths[roop_count]);
tmp_tgt_default_files_char +=
share_alter->tmp_tgt_default_files_lengths[roop_count] + 1;
tmp_tgt_default_groups[roop_count] = tmp_tgt_default_groups_char;
memcpy(tmp_tgt_default_groups_char,
share_alter->tmp_tgt_default_groups[roop_count],
sizeof(char) * share_alter->tmp_tgt_default_groups_lengths[roop_count]);
tmp_tgt_default_groups_char +=
share_alter->tmp_tgt_default_groups_lengths[roop_count] + 1;
if (share_alter->tmp_static_link_ids[roop_count])
if ((len=
sizeof(char) * share_alter->tmp_server_names_lengths[roop_count]))
{
tmp_server_names[roop_count]= tmp_server_names_char;
memcpy(tmp_server_names_char, share_alter->tmp_server_names[roop_count],
len);
tmp_server_names_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_tgt_table_names_lengths[roop_count]))
{
tmp_tgt_table_names[roop_count]= tmp_tgt_table_names_char;
memcpy(tmp_tgt_table_names_char,
share_alter->tmp_tgt_table_names[roop_count], len);
tmp_tgt_table_names_char+= len + 1;
}
if ((len= sizeof(char) * share_alter->tmp_tgt_dbs_lengths[roop_count]))
{
tmp_tgt_dbs[roop_count]= tmp_tgt_dbs_char;
memcpy(tmp_tgt_dbs_char, share_alter->tmp_tgt_dbs[roop_count], len);
tmp_tgt_dbs_char+= len + 1;
}
if ((len= sizeof(char) * share_alter->tmp_tgt_hosts_lengths[roop_count]))
{
tmp_tgt_hosts[roop_count]= tmp_tgt_hosts_char;
memcpy(tmp_tgt_hosts_char, share_alter->tmp_tgt_hosts[roop_count], len);
tmp_tgt_hosts_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_tgt_usernames_lengths[roop_count]))
{
tmp_tgt_usernames[roop_count]= tmp_tgt_usernames_char;
memcpy(tmp_tgt_usernames_char,
share_alter->tmp_tgt_usernames[roop_count], len);
tmp_tgt_usernames_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_tgt_passwords_lengths[roop_count]))
{
tmp_tgt_passwords[roop_count]= tmp_tgt_passwords_char;
memcpy(tmp_tgt_passwords_char,
share_alter->tmp_tgt_passwords[roop_count], len);
tmp_tgt_passwords_char+= len + 1;
}
if ((len= sizeof(char) * share_alter->tmp_tgt_sockets_lengths[roop_count]))
{
tmp_tgt_sockets[roop_count]= tmp_tgt_sockets_char;
memcpy(tmp_tgt_sockets_char, share_alter->tmp_tgt_sockets[roop_count],
len);
tmp_tgt_sockets_char+= len + 1;
}
if ((len=
sizeof(char) * share_alter->tmp_tgt_wrappers_lengths[roop_count]))
{
tmp_tgt_wrappers[roop_count]= tmp_tgt_wrappers_char;
memcpy(tmp_tgt_wrappers_char, share_alter->tmp_tgt_wrappers[roop_count],
len);
tmp_tgt_wrappers_char+= len + 1;
}
if ((len= sizeof(char) * share_alter->tmp_tgt_ssl_cas_lengths[roop_count]))
{
tmp_tgt_ssl_cas[roop_count]= tmp_tgt_ssl_cas_char;
memcpy(tmp_tgt_ssl_cas_char, share_alter->tmp_tgt_ssl_cas[roop_count],
len);
tmp_tgt_ssl_cas_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_tgt_ssl_capaths_lengths[roop_count]))
{
tmp_tgt_ssl_capaths[roop_count]= tmp_tgt_ssl_capaths_char;
memcpy(tmp_tgt_ssl_capaths_char,
share_alter->tmp_tgt_ssl_capaths[roop_count], len);
tmp_tgt_ssl_capaths_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_tgt_ssl_certs_lengths[roop_count]))
{
tmp_tgt_ssl_certs[roop_count]= tmp_tgt_ssl_certs_char;
memcpy(tmp_tgt_ssl_certs_char,
share_alter->tmp_tgt_ssl_certs[roop_count], len);
tmp_tgt_ssl_certs_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_tgt_ssl_ciphers_lengths[roop_count]))
{
tmp_tgt_ssl_ciphers[roop_count]= tmp_tgt_ssl_ciphers_char;
memcpy(tmp_tgt_ssl_ciphers_char,
share_alter->tmp_tgt_ssl_ciphers[roop_count], len);
tmp_tgt_ssl_ciphers_char+= len + 1;
}
if ((len= sizeof(char) * share_alter->tmp_tgt_ssl_keys_lengths[roop_count]))
{
tmp_tgt_ssl_keys[roop_count]= tmp_tgt_ssl_keys_char;
memcpy(tmp_tgt_ssl_keys_char, share_alter->tmp_tgt_ssl_keys[roop_count],
len);
tmp_tgt_ssl_keys_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_tgt_default_files_lengths[roop_count]))
{
tmp_tgt_default_files[roop_count]= tmp_tgt_default_files_char;
memcpy(tmp_tgt_default_files_char,
share_alter->tmp_tgt_default_files[roop_count], len);
tmp_tgt_default_files_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_tgt_default_groups_lengths[roop_count]))
{
tmp_tgt_default_groups[roop_count]= tmp_tgt_default_groups_char;
memcpy(tmp_tgt_default_groups_char,
share_alter->tmp_tgt_default_groups[roop_count], len);
tmp_tgt_default_groups_char+= len + 1;
}
if ((len= sizeof(char) *
share_alter->tmp_static_link_ids_lengths[roop_count]))
{
tmp_static_link_ids[roop_count] = tmp_static_link_ids_char;
memcpy(tmp_static_link_ids_char,
share_alter->tmp_static_link_ids[roop_count],
sizeof(char) * share_alter->tmp_static_link_ids_lengths[roop_count]);
tmp_static_link_ids_char +=
share_alter->tmp_static_link_ids_lengths[roop_count] + 1;
share_alter->tmp_static_link_ids[roop_count], len);
tmp_static_link_ids_char += len + 1;
}
}
......
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