Commit d25cf617 authored by marko's avatar marko

branches/zip: Fix bugs in the fix of Issue #181. Tested inside and

outside Valgrind, with innodb_use_sys_malloc set to 0 and 1.

mem_init(): Invoke ut_mem_init() before mem_pool_create(), because
the latter one will invoke ut_malloc().

srv_general_init(): Do not initialize the memory subsystem (mem_init()).

innobase_init(): Initialize the memory subsystem (mem_init()) before
calling srv_parse_data_file_paths_and_sizes(), which needs ut_malloc().
Call ut_free_all_mem() in error handling to clean up after the mem_init().
parent 6ef25530
...@@ -1982,6 +1982,11 @@ innobase_init( ...@@ -1982,6 +1982,11 @@ innobase_init(
internal_innobase_data_file_path = my_strdup(innobase_data_file_path, internal_innobase_data_file_path = my_strdup(innobase_data_file_path,
MYF(MY_FAE)); MYF(MY_FAE));
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
/* Initialize the InnoDB memory subsystem before calling
ut_malloc() in srv_parse_data_file_paths_and_sizes(). */
mem_init(srv_mem_pool_size);
ret = (bool) srv_parse_data_file_paths_and_sizes( ret = (bool) srv_parse_data_file_paths_and_sizes(
internal_innobase_data_file_path, internal_innobase_data_file_path,
...@@ -1994,8 +1999,10 @@ innobase_init( ...@@ -1994,8 +1999,10 @@ innobase_init(
if (ret == FALSE) { if (ret == FALSE) {
sql_print_error( sql_print_error(
"InnoDB: syntax error in innodb_data_file_path"); "InnoDB: syntax error in innodb_data_file_path");
mem_free_and_error:
my_free(internal_innobase_data_file_path, my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR)); MYF(MY_ALLOW_ZERO_PTR));
ut_free_all_mem();
goto error; goto error;
} }
...@@ -2025,9 +2032,7 @@ innobase_init( ...@@ -2025,9 +2032,7 @@ innobase_init(
sql_print_error("syntax error in innodb_log_group_home_dir, or a " sql_print_error("syntax error in innodb_log_group_home_dir, or a "
"wrong number of mirrored log groups"); "wrong number of mirrored log groups");
my_free(internal_innobase_data_file_path, goto mem_free_and_error;
MYF(MY_ALLOW_ZERO_PTR));
goto error;
} }
/* Validate the file format by animal name */ /* Validate the file format by animal name */
...@@ -2040,9 +2045,7 @@ innobase_init( ...@@ -2040,9 +2045,7 @@ innobase_init(
sql_print_error("InnoDB: wrong innodb_file_format."); sql_print_error("InnoDB: wrong innodb_file_format.");
my_free(internal_innobase_data_file_path, goto mem_free_and_error;
MYF(MY_ALLOW_ZERO_PTR));
goto error;
} }
} else { } else {
/* Set it to the default file format id. Though this /* Set it to the default file format id. Though this
...@@ -2081,10 +2084,7 @@ innobase_init( ...@@ -2081,10 +2084,7 @@ innobase_init(
trx_sys_file_format_id_to_name( trx_sys_file_format_id_to_name(
DICT_TF_FORMAT_MAX)); DICT_TF_FORMAT_MAX));
my_free(internal_innobase_data_file_path, goto mem_free_and_error;
MYF(MY_ALLOW_ZERO_PTR));
goto error;
} }
} }
...@@ -2107,8 +2107,6 @@ innobase_init( ...@@ -2107,8 +2107,6 @@ innobase_init(
srv_buf_pool_size = (ulint) innobase_buffer_pool_size; srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
srv_n_file_io_threads = (ulint) innobase_file_io_threads; srv_n_file_io_threads = (ulint) innobase_file_io_threads;
srv_force_recovery = (ulint) innobase_force_recovery; srv_force_recovery = (ulint) innobase_force_recovery;
...@@ -2156,9 +2154,7 @@ innobase_init( ...@@ -2156,9 +2154,7 @@ innobase_init(
err = innobase_start_or_create_for_mysql(); err = innobase_start_or_create_for_mysql();
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
my_free(internal_innobase_data_file_path, goto mem_free_and_error;
MYF(MY_ALLOW_ZERO_PTR));
goto error;
} }
innobase_open_tables = hash_create(200); innobase_open_tables = hash_create(200);
......
...@@ -356,8 +356,7 @@ void ...@@ -356,8 +356,7 @@ void
srv_free(void); srv_free(void);
/*==========*/ /*==========*/
/************************************************************************* /*************************************************************************
Initializes the synchronization primitives, memory system, and the thread Initializes the synchronization primitives and the thread local storage. */
local storage. */
UNIV_INTERN UNIV_INTERN
void void
srv_general_init(void); srv_general_init(void);
......
...@@ -162,9 +162,8 @@ mem_init( ...@@ -162,9 +162,8 @@ mem_init(
size = 1; size = 1;
} }
mem_comm_pool = mem_pool_create(size);
ut_mem_init(); ut_mem_init();
mem_comm_pool = mem_pool_create(size);
} }
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
......
...@@ -960,8 +960,7 @@ srv_free(void) ...@@ -960,8 +960,7 @@ srv_free(void)
} }
/************************************************************************* /*************************************************************************
Initializes the synchronization primitives, memory system, and the thread Initializes the synchronization primitives and the thread local storage. */
local storage. */
UNIV_INTERN UNIV_INTERN
void void
srv_general_init(void) srv_general_init(void)
...@@ -969,7 +968,6 @@ srv_general_init(void) ...@@ -969,7 +968,6 @@ srv_general_init(void)
{ {
os_sync_init(); os_sync_init();
sync_init(); sync_init();
mem_init(srv_mem_pool_size);
thr_local_init(); thr_local_init();
} }
......
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