Added asan options to mysql-test-run

- Leak detection is now enabled by default
- Also added to mysql-test suppression files for asan and lsan
This commit is contained in:
Monty 2019-08-15 23:42:07 +03:00 committed by Sergei Golubchik
parent 97dd057702
commit d90fa9ad28
13 changed files with 86 additions and 3 deletions

1
mysql-test/asan.supp Normal file
View file

@ -0,0 +1 @@
# Asan suppressions

View file

@ -0,0 +1,8 @@
# This file should only be used with test that finds bugs in ASan that can not
# be overcome. In normal cases one should fix the bug server/test case or in
# the worst case add a (temporary?) suppression in asan.supp or lsan.supp
if (`select @@have_sanitizer <> 'NO'`)
{
--skip Can't be run with ASan
}

17
mysql-test/lsan.supp Normal file
View file

@ -0,0 +1,17 @@
# LSAN (Asan leaks) suppressions
# Leaks found by main.tls_version1
leak:gnutls_certificate_allocate_credentials
leak:gnutls_x509_trust_list_init
# Leaks found by openssl_1
leak:libtasn1
leak:libgnutls
leak:gnutls_pubkey_init
leak:gnutls_x509_privkey_init
leak:gnutls_x509_crt_init
leak:gnutls_privkey_init
leak:gnutls_x509_trust_list_init
leak:gnutls_subject_alt_names_init
leak:__gmp_default_allocate
leak:__gmp_default_reallocate

View file

@ -1,5 +1,6 @@
# Needed for mysqldump
--source include/have_utf8mb4.inc
--source include/not_asan.inc
# Tests for SSL connections, only run if mysqld is compiled
# with support for SSL.

View file

@ -1772,12 +1772,24 @@ sub command_line_setup {
# --------------------------------------------------------------------------
# Check debug related options
# --------------------------------------------------------------------------
$ENV{ASAN_OPTIONS}= "abort_on_error=1:" . ($ENV{ASAN_OPTIONS} || '');
$ENV{ASAN_OPTIONS}= "suppressions=${glob_mysql_test_dir}/asan.supp:" .
$ENV{ASAN_OPTIONS}
if -f "$glob_mysql_test_dir/asan.supp";
# The following can be useful when a test fails without any asan report
# on stderr like with openssl_1.test
# $ENV{ASAN_OPTIONS}= "log_path=${opt_vardir}/log/asan:" . $ENV{ASAN_OPTIONS};
# Add leak suppressions
$ENV{LSAN_OPTIONS}= "suppressions=${glob_mysql_test_dir}/lsan.supp"
if -f "$glob_mysql_test_dir/lsan.supp";
if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
$opt_manual_gdb || $opt_manual_lldb || $opt_manual_ddd ||
$opt_manual_debug || $opt_dbx || $opt_client_dbx || $opt_manual_dbx ||
$opt_debugger || $opt_client_debugger )
{
$ENV{ASAN_OPTIONS}= 'abort_on_error=1:'.($ENV{ASAN_OPTIONS} || '');
$ENV{ASAN_OPTIONS}= 'disable_coredump=0:'. $ENV{ASAN_OPTIONS};
if ( using_extern() )
{
mtr_error("Can't use --extern when using debugger");

View file

@ -22,6 +22,7 @@ select * from information_schema.system_variables
'in_predicate_conversion_threshold',
'have_openssl',
'have_symlink',
'have_sanitizer',
'hostname',
'large_files_support', 'log_tc_size',
'lower_case_file_system',
@ -48,6 +49,7 @@ select VARIABLE_NAME, VARIABLE_SCOPE, VARIABLE_TYPE, VARIABLE_COMMENT,
where variable_name in (
'have_openssl',
'have_symlink',
'have_sanitizer',
'hostname',
'large_files_support',
'lower_case_file_system',

View file

@ -11,6 +11,7 @@ variable_name not in (
'in_predicate_conversion_threshold',
'have_openssl',
'have_symlink',
'have_sanitizer',
'hostname',
'large_files_support', 'log_tc_size',
'lower_case_file_system',
@ -4654,6 +4655,7 @@ from information_schema.system_variables
where variable_name in (
'have_openssl',
'have_symlink',
'have_sanitizer',
'hostname',
'large_files_support',
'lower_case_file_system',
@ -4679,6 +4681,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME HAVE_SANITIZER
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
VARIABLE_COMMENT If the server is compiled with ASan (Address sanitizer) this will be set to YES, otherwise will be set to NO
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME HAVE_SYMLINK
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR

View file

@ -11,6 +11,7 @@ variable_name not in (
'in_predicate_conversion_threshold',
'have_openssl',
'have_symlink',
'have_sanitizer',
'hostname',
'large_files_support', 'log_tc_size',
'lower_case_file_system',
@ -5746,6 +5747,7 @@ from information_schema.system_variables
where variable_name in (
'have_openssl',
'have_symlink',
'have_sanitizer',
'hostname',
'large_files_support',
'lower_case_file_system',
@ -5771,6 +5773,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME HAVE_SANITIZER
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
VARIABLE_COMMENT If the server is compiled with ASan (Address sanitizer) this will be set to YES, otherwise will be set to NO
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME HAVE_SYMLINK
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR

View file

@ -675,7 +675,7 @@ MY_LOCALE *my_default_lc_time_names;
SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen, have_query_cache;
SHOW_COMP_OPTION have_geometry, have_rtree_keys;
SHOW_COMP_OPTION have_crypt, have_compress;
SHOW_COMP_OPTION have_crypt, have_compress, have_sanitizer;
SHOW_COMP_OPTION have_profiling;
SHOW_COMP_OPTION have_openssl;
@ -7957,6 +7957,14 @@ static int mysql_init_variables(void)
#endif /* ! EMBEDDED_LIBRARY */
#endif /* HAVE_OPENSSL */
have_sanitizer= SHOW_OPTION_NO;
#if defined(__has_feature)
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
have_sanitizer= SHOW_OPTION_YES;
#endif
#endif
#if defined(__WIN__)
/* Allow Win32 users to move MySQL anywhere */
{

View file

@ -393,7 +393,7 @@ extern SHOW_COMP_OPTION have_csv, have_innodb;
extern SHOW_COMP_OPTION have_ndbcluster, have_partitioning;
extern SHOW_COMP_OPTION have_profiling;
extern SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen;
extern SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen, have_sanitizer;
extern SHOW_COMP_OPTION have_query_cache;
extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
extern SHOW_COMP_OPTION have_crypt;

View file

@ -4808,6 +4808,12 @@ static Sys_var_have Sys_have_rtree_keys(
"are available, will be set to YES, otherwise will be set to NO.",
READ_ONLY GLOBAL_VAR(have_rtree_keys), NO_CMD_LINE);
static Sys_var_have Sys_have_santitizer(
"have_sanitizer",
"If the server is compiled with ASan (Address sanitizer) this will be "
"set to YES, otherwise will be set to NO",
READ_ONLY GLOBAL_VAR(have_sanitizer), NO_CMD_LINE);
static Sys_var_have Sys_have_ssl(
"have_ssl", "If the server supports secure connections, will be set to YES, "
"otherwise will be set to NO. If set to DISABLED, the server was compiled with "

View file

@ -2,6 +2,8 @@
source include/have_tokudb.inc;
source include/big_test.inc;
# ASan causes test to timeout
source include/not_asan.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;

View file

@ -49,6 +49,8 @@ let $more_pk_ui_tests= 0;
--source include/big_test.inc
# Skiping this test from Valgrind execution as per Bug-14627884
--source include/not_valgrind.inc
# Don't run with asan as it causes timeouts
--source include/not_asan.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements