diff options
author | Michael Widenius <monty@askmonty.org> | 2011-06-11 14:28:15 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-06-11 14:28:15 +0300 |
commit | 69ffc06610136c45d79f5e430373ee9ce4c78cb5 (patch) | |
tree | 6e3a89bcb42233351cda58c0372ebf07e56e1510 /storage/archive | |
parent | 13f55aac67343450d1c2872dd238d81093d09f11 (diff) | |
download | mariadb-git-69ffc06610136c45d79f5e430373ee9ce4c78cb5.tar.gz |
Fixes BUG#60976 "Crash, valgrind warning and memory leak with partitioned archive tables"
Noted that there was no memory leak, just a lot of used partitioned tables.
Fixed old bug: 'show status' now shows memory usage when compiled with safemalloc.
Added option --flush to mysqlcheck.c to run a 'flush tables' between each check to keep down memory usage.
Changed '--safemalloc' options to mysqld so that one can use --safemalloc and --skip-safemalloc.
Now skip-safemalloc is default (ie, we only do checking of memory overrun during free()) to speed up tests.
client/client_priv.h:
Added OPT_FLUSH_TABLES
client/mysqlcheck.c:
Added option --flush to mysqlcheck.c to run a 'flush tables' between each check to keep down memory usage.
mysql-test/mysql-test-run.pl:
Always run tests with --loose-skip-safemysqld for higher speed
sql/mysqld.cc:
Changed '--safemalloc' options so that one can use --safemalloc and --skip-safemalloc.
Now skip-safemalloc is default (ie, we only do checking of memory overrun during free()) to speed up tests
sql/sql_parse.cc:
Fixed old bug: 'show status' now shows memory usage when compiled with safemalloc.
storage/archive/archive_reader.c:
Changed all malloc() calls to use my_malloc()/my_free()
Added checks of malloc() calls.
storage/archive/ha_archive.cc:
Detect failure if init_archive_reader() and return errno. This fixed assert crash in my_seek().
Changed all malloc() calls to use my_malloc()/my_free()
Diffstat (limited to 'storage/archive')
-rw-r--r-- | storage/archive/archive_reader.c | 20 | ||||
-rw-r--r-- | storage/archive/ha_archive.cc | 22 |
2 files changed, 26 insertions, 16 deletions
diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c index 0cf795cefdf..90220f26f6d 100644 --- a/storage/archive/archive_reader.c +++ b/storage/archive/archive_reader.c @@ -93,12 +93,16 @@ int main(int argc, char *argv[]) printf("\tFRM length %u\n", reader_handle.frm_length); if (reader_handle.comment_start_pos) { - char *comment = - (char *) malloc(sizeof(char) * reader_handle.comment_length); - azread_comment(&reader_handle, comment); - printf("\tComment length %u\n\t\t%.*s\n", reader_handle.comment_length, - reader_handle.comment_length, comment); - free(comment); + char *comment = (char *) my_malloc(reader_handle.comment_length, + MYF(MY_WME)); + if (comment) + { + azread_comment(&reader_handle, comment); + printf("\tComment length %u\n\t\t%.*s\n", + reader_handle.comment_length, + reader_handle.comment_length, comment); + my_free(comment,MYF(0)); + } } } else @@ -180,7 +184,7 @@ int main(int argc, char *argv[]) azio_stream writer_handle; - buffer= (char *)malloc(reader_handle.longest_row); + buffer= (char *) my_malloc(reader_handle.longest_row, MYF(0)); if (buffer == NULL) { printf("Could not allocate memory for row %llu\n", row_count); @@ -251,7 +255,7 @@ int main(int argc, char *argv[]) break; } - free(buffer); + my_free(buffer, MYF(0)); azclose(&writer_handle); } diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index d70de0dd13c..730d5b95abb 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -835,7 +835,7 @@ int ha_archive::write_row(uchar *buf) if (!share->archive_write_open) if (init_archive_writer()) - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + DBUG_RETURN(errno); if (table->next_number_field && record == table->record[0]) @@ -1020,7 +1020,8 @@ int ha_archive::rnd_init(bool scan) if (share->crashed) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); - init_archive_reader(); + if (init_archive_reader()) + DBUG_RETURN(errno); /* We rewind the file so that we can read from the beginning if scan */ if (scan) @@ -1317,7 +1318,8 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) char* frm_string; DBUG_ENTER("ha_archive::optimize"); - init_archive_reader(); + if (init_archive_reader()) + DBUG_RETURN(errno); // now we close both our writer and our reader for the rename if (share->archive_write_open) @@ -1326,7 +1328,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) share->archive_write_open= FALSE; } - if (!(frm_string= (char*) malloc(archive.frm_length))) + if (!(frm_string= (char*) my_malloc(archive.frm_length, MYF(0)))) return ENOMEM; azread_frm(&archive, frm_string); @@ -1337,12 +1339,12 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY))) { - free(frm_string); + my_free(frm_string, MYF(0)); DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); } rc= azwrite_frm(&writer, frm_string, archive.frm_length); - free(frm_string); + my_free(frm_string, MYF(0)); if (rc) { rc= HA_ERR_CRASHED_ON_USAGE; @@ -1547,7 +1549,9 @@ int ha_archive::info(uint flag) if (flag & HA_STATUS_AUTO) { - init_archive_reader(); + if (init_archive_reader()) + DBUG_RETURN(errno); + pthread_mutex_lock(&share->mutex); azflush(&archive, Z_SYNC_FLUSH); pthread_mutex_unlock(&share->mutex); @@ -1626,7 +1630,9 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) Now we will rewind the archive file so that we are positioned at the start of the file. */ - init_archive_reader(); + if (init_archive_reader()) + DBUG_RETURN(errno); + read_data_header(&archive); while (!(rc= get_row(&archive, table->record[0]))) count--; |