diff --git a/mysql-test/asan.supp b/mysql-test/asan.supp new file mode 100644 index 00000000000..1bfd4fd0b17 --- /dev/null +++ b/mysql-test/asan.supp @@ -0,0 +1 @@ +# Asan suppressions diff --git a/mysql-test/include/not_asan.inc b/mysql-test/include/not_asan.inc new file mode 100644 index 00000000000..e61a1faec39 --- /dev/null +++ b/mysql-test/include/not_asan.inc @@ -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 +} diff --git a/mysql-test/lsan.supp b/mysql-test/lsan.supp new file mode 100644 index 00000000000..3f460d4544e --- /dev/null +++ b/mysql-test/lsan.supp @@ -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 diff --git a/mysql-test/main/openssl_1.test b/mysql-test/main/openssl_1.test index 27eeb0198b1..40b79c47486 100644 --- a/mysql-test/main/openssl_1.test +++ b/mysql-test/main/openssl_1.test @@ -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. diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index faf7a24b34e..214a6126f71 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -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"); diff --git a/mysql-test/suite/sys_vars/inc/sysvars_server.inc b/mysql-test/suite/sys_vars/inc/sysvars_server.inc index 56053449bae..0f4418f55e5 100644 --- a/mysql-test/suite/sys_vars/inc/sysvars_server.inc +++ b/mysql-test/suite/sys_vars/inc/sysvars_server.inc @@ -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', diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 0b587ab82c2..147e378c240 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -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 diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index cd39a9e9882..d73880cd21b 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -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 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 689258158a1..2b5ce8d9f9f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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 */ { diff --git a/sql/set_var.h b/sql/set_var.h index 7f551875c97..88a4f42e729 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -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; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 2e7c5e7f442..12ad7828e68 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -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 " diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_delete.test b/storage/tokudb/mysql-test/tokudb/t/bf_delete.test index a55d78784cc..cdfb5dbc1a6 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_delete.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_delete.test @@ -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; diff --git a/storage/tokudb/mysql-test/tokudb_parts/t/partition_alter4_tokudb.test b/storage/tokudb/mysql-test/tokudb_parts/t/partition_alter4_tokudb.test index 93a3a0cbdce..e450574634b 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/t/partition_alter4_tokudb.test +++ b/storage/tokudb/mysql-test/tokudb_parts/t/partition_alter4_tokudb.test @@ -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