diff options
author | Michael Widenius <monty@askmonty.org> | 2013-06-19 22:57:46 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-06-19 22:57:46 +0300 |
commit | f62f4bd563a96ddd78b78d563e4d4cf5ad27aae1 (patch) | |
tree | 17d34be40ccafdbb0ffee956c87aa86bf3aef3fc | |
parent | dfcc502ab540b4d93fe3d40d0bac15fa3ae449dd (diff) | |
download | mariadb-git-f62f4bd563a96ddd78b78d563e4d4cf5ad27aae1.tar.gz |
Fixed some memory leaks
Disabled some asserts that we can't yet have enabled
-rw-r--r-- | mysys/safemalloc.c | 4 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | sql/sp_head.cc | 9 | ||||
-rw-r--r-- | sql/sql_base.cc | 1 | ||||
-rw-r--r-- | sql/sql_class.cc | 4 | ||||
-rw-r--r-- | sql/sql_error.cc | 6 | ||||
-rw-r--r-- | sql/sql_error.h | 3 | ||||
-rw-r--r-- | sql/sql_get_diagnostics.cc | 2 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 4 | ||||
-rw-r--r-- | sql/sys_vars.cc | 2 | ||||
-rw-r--r-- | storage/perfschema/pfs_instr.cc | 2 | ||||
-rw-r--r-- | storage/perfschema/pfs_setup_object.cc | 2 |
12 files changed, 29 insertions, 14 deletions
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index bdcfe4480db..f1fc9366c2f 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -373,8 +373,8 @@ void sf_report_leaked_memory(my_thread_id id) { my_thread_id tid = irem->thread_id && irem->flags & MY_THREAD_SPECIFIC ? irem->thread_id : 0; - fprintf(stderr, "Warning: %4lu bytes lost, allocated by T@%lu at ", - (ulong) irem->datasize,tid); + fprintf(stderr, "Warning: %4lu bytes lost at %p, allocated by T@%lu at ", + (ulong) irem->datasize, (char*) (irem + 1), tid); print_stack(irem->frame); total+= irem->datasize; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 260427c1e2b..8c1760dd7b9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3624,13 +3624,15 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific) However, this should never happen, so better to assert and fix this. */ +#ifdef ENABLE_BEFORE_END_OF_MERGE_QQ DBUG_ASSERT(thd); +#endif if (thd) { DBUG_PRINT("info", ("memory_used: %lld size: %lld", (longlong) thd->status_var.memory_used, size)); thd->status_var.memory_used+= size; -#ifndef ENABLE_BEFORE_END_OF_MERGE +#ifdef ENABLE_BEFORE_END_OF_MERGE_QQ DBUG_ASSERT((longlong) thd->status_var.memory_used >= 0); #endif } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 03631e107db..67fb3cb6102 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1969,8 +1969,9 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (! octx) { /* Create a temporary old context. */ + if (!(octx= sp_rcontext::create(thd, m_pcont, NULL))) { - delete octx; /* Delete octx if it was init() that failed. */ + DBUG_PRINT("error", ("Could not create octx")); DBUG_RETURN(TRUE); } @@ -2034,6 +2035,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (!null_item || nctx->set_variable(thd, i, &tmp_item)) { + DBUG_PRINT("error", ("set variable failed")); err_status= TRUE; break; } @@ -2042,6 +2044,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) { if (nctx->set_variable(thd, i, it_args.ref())) { + DBUG_PRINT("error", ("set variable 2 failed")); err_status= TRUE; break; } @@ -2098,7 +2101,10 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) #endif if (!err_status) + { err_status= execute(thd, TRUE); + DBUG_PRINT("info", ("execute returned %d", (int) err_status)); + } if (save_log_general) thd->variables.option_bits &= ~OPTION_LOG_OFF; @@ -2138,6 +2144,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (srp->set_value(thd, octx, nctx->get_item_addr(i))) { + DBUG_PRINT("error", ("set value failed")); err_status= TRUE; break; } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e223b521bfb..a2220a59470 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -440,6 +440,7 @@ static void table_def_free_entry(TABLE_SHARE *share) bool table_def_init(void) { + table_def_inited= 1; #ifdef HAVE_PSI_INTERFACE init_tdc_psi_keys(); #endif diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4f19b18b126..13fb6de573c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -857,7 +857,7 @@ THD::THD() #if defined(ENABLED_DEBUG_SYNC) debug_sync_control(0), #endif /* defined(ENABLED_DEBUG_SYNC) */ - main_da(0, false), + main_da(0, false, false), m_stmt_da(&main_da) { ulong tmp; @@ -1561,7 +1561,9 @@ THD::~THD() { DBUG_PRINT("error", ("memory_used: %lld", status_var.memory_used)); SAFEMALLOC_REPORT_MEMORY(my_thread_dbug_id()); +#ifdef ENABLE_BEFORE_END_OF_MERGE_QQ DBUG_ASSERT(status_var.memory_used == 0); // Ensure everything is freed +#endif } set_current_thd(orig_thd); diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 2fb16a49c2b..e1c4fa5ee40 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -327,8 +327,9 @@ Diagnostics_area::Diagnostics_area(bool initialize) } Diagnostics_area::Diagnostics_area(ulonglong warning_info_id, - bool allow_unlimited_warnings) - : m_main_wi(warning_info_id, allow_unlimited_warnings, true) + bool allow_unlimited_warnings, + bool initialize) + : m_main_wi(warning_info_id, allow_unlimited_warnings, initialize) { push_warning_info(&m_main_wi); @@ -527,6 +528,7 @@ Warning_info::Warning_info(ulonglong warn_id_arg, void Warning_info::init() { /* Initialize sub structures */ + DBUG_ASSERT(initialized == 0); init_sql_alloc(&m_warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE, MYF(MY_THREAD_SPECIFIC)); initialized= 1; diff --git a/sql/sql_error.h b/sql/sql_error.h index fb6cdfcfede..70805d93450 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -713,7 +713,8 @@ public: } Diagnostics_area(bool initialize); - Diagnostics_area(ulonglong warning_info_id, bool allow_unlimited_warnings); + Diagnostics_area(ulonglong warning_info_id, bool allow_unlimited_warnings, + bool initialize); void init() { m_main_wi.init() ; } void free_memory() { m_main_wi.free_memory() ; } diff --git a/sql/sql_get_diagnostics.cc b/sql/sql_get_diagnostics.cc index 24850e44d59..be1e3589cc6 100644 --- a/sql/sql_get_diagnostics.cc +++ b/sql/sql_get_diagnostics.cc @@ -43,7 +43,7 @@ bool Sql_cmd_get_diagnostics::execute(THD *thd) { bool rv; - Diagnostics_area new_stmt_da(thd->query_id, false); + Diagnostics_area new_stmt_da(thd->query_id, false, true); Diagnostics_area *save_stmt_da= thd->get_stmt_da(); DBUG_ENTER("Sql_cmd_get_diagnostics::execute"); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index f3c6023de70..85f89fc185a 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2993,7 +2993,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) param= stmt->param_array[param_number]; - Diagnostics_area new_stmt_da(thd->query_id, false); + Diagnostics_area new_stmt_da(thd->query_id, false, true); Diagnostics_area *save_stmt_da= thd->get_stmt_da(); thd->set_stmt_da(&new_stmt_da); @@ -4066,7 +4066,7 @@ Ed_result_set::Ed_result_set(List<Ed_row> *rows_arg, */ Ed_connection::Ed_connection(THD *thd) - :m_diagnostics_area(thd->query_id, false), + :m_diagnostics_area(thd->query_id, false, true), m_thd(thd), m_rsets(0), m_current_rset(0) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 4c0aeef9c06..d87c877ea6d 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -72,7 +72,7 @@ static Sys_var_mybool Sys_pfs_enabled( "performance_schema", "Enable the performance schema.", - READ_ONLY GLOBAL_VAR(pfs_param.m_enabled), + PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_enabled), CMD_LINE(OPT_ARG), DEFAULT(TRUE)); static Sys_var_long Sys_pfs_events_waits_history_long_size( diff --git a/storage/perfschema/pfs_instr.cc b/storage/perfschema/pfs_instr.cc index 68ec8b149a3..dd8f21a262c 100644 --- a/storage/perfschema/pfs_instr.cc +++ b/storage/perfschema/pfs_instr.cc @@ -797,7 +797,7 @@ PFS_cond* create_cond(PFS_cond_class *klass, const void *identity) */ void destroy_cond(PFS_cond *pfs) { - DBUG_ENTER("destroy_thread"); + DBUG_ENTER("destroy_cond"); DBUG_ASSERT(pfs != NULL); PFS_cond_class *klass= pfs->m_class; diff --git a/storage/perfschema/pfs_setup_object.cc b/storage/perfschema/pfs_setup_object.cc index 0ca7986e818..eaded47f60b 100644 --- a/storage/perfschema/pfs_setup_object.cc +++ b/storage/perfschema/pfs_setup_object.cc @@ -110,8 +110,8 @@ void cleanup_setup_object_hash(void) { if (setup_object_hash_inited) { - lf_hash_destroy(&setup_object_hash); setup_object_hash_inited= false; + lf_hash_destroy(&setup_object_hash); } } |