diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-07-08 18:20:08 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-07-08 18:20:08 -0300 |
commit | a10ae35328ec800eff63c0bbb06d279e44c0a5a1 (patch) | |
tree | 6c88c3c07b30acb464ca8bf81bbef916216da616 /sql/mysqld.cc | |
parent | d4cd1f843da60019664dfad2b0ad6987f82f01c6 (diff) | |
download | mariadb-git-a10ae35328ec800eff63c0bbb06d279e44c0a5a1.tar.gz |
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 28cad51aa41..35d6137789d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1523,7 +1523,7 @@ void clean_up(bool print_message) if (defaults_argv) free_defaults(defaults_argv); free_tmpdir(&mysql_tmpdir_list); - x_free(opt_bin_logname); + my_free(opt_bin_logname); bitmap_free(&temp_pool); free_max_user_conn(); #ifdef HAVE_REPLICATION @@ -3135,7 +3135,7 @@ void *my_str_malloc_mysqld(size_t size) void my_str_free_mysqld(void *ptr) { - my_free(ptr, MYF(MY_FAE)); + my_free(ptr); } #endif /* EMBEDDED_LIBRARY */ @@ -3708,7 +3708,7 @@ static int init_common_variables() #define FIX_LOG_VAR(VAR, ALT) \ if (!VAR || !*VAR) \ { \ - x_free(VAR); /* it could be an allocated empty string "" */ \ + my_free(VAR); /* it could be an allocated empty string "" */ \ VAR= my_strdup(ALT, MYF(0)); \ } @@ -4144,7 +4144,7 @@ a file name for --log-bin-index option", opt_binlog_index_name); } if (ln == buf) { - my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR)); + my_free(opt_bin_logname); opt_bin_logname=my_strdup(buf, MYF(0)); } if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln, TRUE)) @@ -5931,7 +5931,7 @@ errorconn: /* End shared memory handling */ error: if (tmp) - my_free(tmp, MYF(0)); + my_free(tmp); if (errmsg) { @@ -6231,14 +6231,6 @@ struct my_option my_long_options[]= "Don't allow new user creation by the user who has no write privileges to the mysql.user table.", &opt_safe_user_create, &opt_safe_user_create, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, -#if !defined(DBUG_OFF) && defined(SAFEMALLOC) - {"safemalloc", 0, "Enable the memory allocation checking.", - &sf_malloc_quick, &sf_malloc_quick, 0, - GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"safemalloc-mem-limit", 0, "Simulate memory shortage.", - &sf_malloc_mem_limit, &sf_malloc_mem_limit, 0, GET_UINT, - REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, -#endif {"show-slave-auth-info", 0, "Show user and password in SHOW SLAVE HOSTS on this master.", &opt_show_slave_auth_info, &opt_show_slave_auth_info, 0, @@ -7867,7 +7859,7 @@ static int fix_paths(void) } char *secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE)); convert_dirname(secure_file_real_path, buff, NullS); - my_free(opt_secure_file_priv, MYF(0)); + my_free(opt_secure_file_priv); opt_secure_file_priv= secure_file_real_path; } } |