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 | f56dd32bf7c5b8a8cf35984f39f1a253b75945ff (patch) | |
tree | 6c88c3c07b30acb464ca8bf81bbef916216da616 /storage/heap | |
parent | d3b01fef18b20f3ac589f2ecc95d64326570583f (diff) | |
download | mariadb-git-f56dd32bf7c5b8a8cf35984f39f1a253b75945ff.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.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
Diffstat (limited to 'storage/heap')
-rw-r--r-- | storage/heap/ha_heap.cc | 4 | ||||
-rw-r--r-- | storage/heap/hp_block.c | 2 | ||||
-rw-r--r-- | storage/heap/hp_close.c | 2 | ||||
-rw-r--r-- | storage/heap/hp_create.c | 6 | ||||
-rw-r--r-- | storage/heap/hp_rename.c | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 541650bd5e8..350958f8230 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -112,7 +112,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) create_info.pin_share= TRUE; rc= heap_create(name, &create_info, &internal_share, &created_new_share); - my_free((uchar*) create_info.keydef, MYF(0)); + my_free(create_info.keydef); if (rc) goto end; @@ -764,7 +764,7 @@ int ha_heap::create(const char *name, TABLE *table_arg, hp_create_info.auto_increment= (create_info->auto_increment_value ? create_info->auto_increment_value - 1 : 0); error= heap_create(name, &hp_create_info, &internal_share, &created); - my_free((uchar*) hp_create_info.keydef, MYF(0)); + my_free(hp_create_info.keydef); DBUG_ASSERT(file == 0); return (error); } diff --git a/storage/heap/hp_block.c b/storage/heap/hp_block.c index c622a9e52f8..7f6cc1ef90a 100644 --- a/storage/heap/hp_block.c +++ b/storage/heap/hp_block.c @@ -145,7 +145,7 @@ uchar *hp_free_level(HP_BLOCK *block, uint level, HP_PTRS *pos, uchar *last_pos) } if ((uchar*) pos != last_pos) { - my_free((uchar*) pos,MYF(0)); + my_free(pos); return last_pos; } return next_ptr; /* next memory position */ diff --git a/storage/heap/hp_close.c b/storage/heap/hp_close.c index 49d8ec376bb..e5a826423db 100644 --- a/storage/heap/hp_close.c +++ b/storage/heap/hp_close.c @@ -46,6 +46,6 @@ int hp_close(register HP_INFO *info) heap_open_list=list_delete(heap_open_list,&info->open_list); if (!--info->s->open_count && info->s->delete_on_close) hp_free(info->s); /* Table was deleted */ - my_free((uchar*) info,MYF(0)); + my_free(info); DBUG_RETURN(error); } diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index cf0f5d5ba6d..bbf649c5e46 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -189,7 +189,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, /* Must be allocated separately for rename to work */ if (!(share->name= my_strdup(name,MYF(0)))) { - my_free((uchar*) share,MYF(0)); + my_free(share); goto err; } #ifdef THREAD @@ -305,7 +305,7 @@ void hp_free(HP_SHARE *share) thr_lock_delete(&share->lock); mysql_mutex_destroy(&share->intern_lock); #endif - my_free((uchar*) share->name, MYF(0)); - my_free((uchar*) share, MYF(0)); + my_free(share->name); + my_free(share); return; } diff --git a/storage/heap/hp_rename.c b/storage/heap/hp_rename.c index c4e8390cc43..cf0d2b2b387 100644 --- a/storage/heap/hp_rename.c +++ b/storage/heap/hp_rename.c @@ -33,7 +33,7 @@ int heap_rename(const char *old_name, const char *new_name) mysql_mutex_unlock(&THR_LOCK_heap); DBUG_RETURN(my_errno); } - my_free(info->name,MYF(0)); + my_free(info->name); info->name=name_buff; } mysql_mutex_unlock(&THR_LOCK_heap); |