mariadb/mysys
Davi Arnaut f56dd32bf7 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.
2010-07-08 18:20:08 -03:00
..
array.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
base64.c fixed compilation warnings. addendum to the fix for bug 29125 2009-03-20 16:27:53 +02:00
ChangeLog
charset-def.c Backporting WL#1213 2010-02-24 13:15:34 +04:00
charset.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
checksum.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
CMakeLists.txt Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
default.c Manual merge from mysql-trunk-merge. 2010-02-24 16:52:27 +03:00
default_modify.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
errors.c Backport of: 2009-11-24 16:54:59 +03:00
hash.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
lf_alloc-pin.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
lf_dynarray.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
lf_hash.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
list.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
make-conf.c Many files: 2006-12-23 20:17:15 +01:00
Makefile.am Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
md5.c Bug #42434: license of mysys MD5 implementation is not GPL-compatible 2009-03-09 20:57:03 +02:00
mf_arr_appstr.c Bug #20748: Configuration files should not be read more than once 2007-11-07 15:23:50 -07:00
mf_brkhant.c Many files: 2006-12-23 20:17:15 +01:00
mf_cache.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
mf_dirname.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_fn_ext.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_format.c BUG#43949 Initialization of slave produces a warning message in Valgrind 2009-04-19 02:21:33 +01:00
mf_getdate.c Merge from 5.0-bugteam 2009-05-13 08:48:00 -07:00
mf_iocache.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
mf_iocache2.c WL#2360 Performance schema 2009-12-09 20:19:51 -07:00
mf_keycache.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
mf_keycaches.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
mf_loadpath.c Manual merge of mysql-5.1-bugteam to mysql-trunk-merge. 2010-05-09 02:03:35 +04:00
mf_pack.c Bug #51893: crash with certain characters given to load_file 2010-03-23 16:54:16 +02:00
mf_path.c Backport of: 2009-11-24 16:54:59 +03:00
mf_qsort.c Fix for bug #31207: Test "join_nested" shows different strategy on IA64 2007-10-17 20:08:58 +04:00
mf_qsort2.c Many files: 2006-12-23 20:17:15 +01:00
mf_radix.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_same.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_sort.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
mf_soundex.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_tempdir.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
mf_tempfile.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
mf_unixpath.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_util.c Many files: 2006-12-23 20:17:15 +01:00
mf_wcomp.c Many files: 2006-12-23 20:17:15 +01:00
mf_wfile.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
mulalloc.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_access.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_aes.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_alarm.c Many files: 2006-12-23 20:17:15 +01:00
my_alloc.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_append.c Backport of: 2009-11-24 16:54:59 +03:00
my_atomic.c WL#2595 kernel-independent atomic operations 2009-11-17 17:11:32 -07:00
my_bit.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_bitmap.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_chsize.c This is the downport of 2009-09-11 22:26:35 +02:00
my_clock.c Backport of: 2009-11-24 16:54:59 +03:00
my_compress.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_conio.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
my_copy.c Backport of: 2009-11-24 16:54:59 +03:00
my_crc32.c Many files: 2006-12-23 20:17:15 +01:00
my_create.c WL#5161 : Cross-platform build with CMake 2009-11-09 12:32:48 +01:00
my_delete.c Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111 2010-06-25 19:32:59 +04:00
my_div.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_dup.c This is the downport of 2009-09-11 22:26:35 +02:00
my_error.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_file.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_fopen.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_fstream.c Backport of: 2009-11-24 16:54:59 +03:00
my_gethostbyname.c WL#2360 Performance schema 2009-12-09 20:19:51 -07:00
my_gethwaddr.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_getncpus.c WL#2595 kernel-independent atomic operations 2009-11-17 17:11:32 -07:00
my_getopt.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_getpagesize.c Many files: 2006-12-23 20:17:15 +01:00
my_getsystime.c merge 2009-12-19 03:21:49 +01:00
my_getwd.c Fixed loaddata failures on some platforms in PB2. 2010-05-11 20:10:52 +04:00
my_handler.c Fix AIX error during compile in my_handler (pointer to data is used, while pointer to function is expected). 2010-01-19 18:22:51 +01:00
my_handler_errors.h WL#5016: Fix header file include guards 2009-09-23 23:32:31 +02:00
my_init.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_largepage.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_lib.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_libwrap.c Many files: 2006-12-23 20:17:15 +01:00
my_lock.c WL#2360 Performance schema 2009-12-09 20:19:51 -07:00
my_lockmem.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_malloc.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_memmem.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_mess.c Backport: remove dead code. 2010-05-28 19:53:26 -03:00
my_mkdir.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_mmap.c Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111 2010-06-25 19:32:59 +04:00
my_net.c WL#2360 Performance schema 2009-12-09 20:19:51 -07:00
my_netware.c Many files: 2006-12-23 20:17:15 +01:00
my_new.cc Bug#43461: invalid comparison with string literal in default.c 2009-03-19 17:20:15 -03:00
my_once.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_open.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_port.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_pread.c WL#2360 Performance schema 2009-12-09 20:19:51 -07:00
my_pthread.c Backport: Remove unused and ancient files, functions, and facilities. 2010-05-28 19:13:31 -03:00
my_quick.c This is the downport of 2009-09-11 22:26:35 +02:00
my_rdtsc.c remove use of undocumented __sparcv8plus - this macro does not seem to be defined anymore with Sun Studio 12 2010-02-14 14:32:27 +01:00
my_read.c This is the downport of 2009-09-11 22:26:35 +02:00
my_redel.c Backport of: 2009-11-24 16:54:59 +03:00
my_rename.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_seek.c This is the downport of 2009-09-11 22:26:35 +02:00
my_sleep.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_static.c Backport: remove dead code. 2010-05-28 19:53:26 -03:00
my_static.h WL#5016: Fix header file include guards 2009-09-23 23:32:31 +02:00
my_symlink.c Bug#39102 valgrind build does not compile in realpath, which make DATA/INDEX DIR fail 2008-10-27 19:25:11 +04:00
my_symlink2.c Merge mysql.com:/home/svoj/devel/mysql/BUG32111/mysql-5.0-engines 2007-11-12 15:26:37 +04:00
my_sync.c Manual merge from mysql-trunk. 2009-12-11 12:39:38 +03:00
my_thr_init.c Bug #50362 comp_err crashes during compilation on FreeBSD. 2010-01-20 14:04:17 +01:00
my_timer_cycles.il WL#2373 Use cycle counter for timing 2009-11-24 16:36:31 -07:00
my_vle.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_wincond.c A follow up for the fix for Bug#35164 (remove priorities on Windows). 2009-11-23 20:08:37 +03:00
my_windac.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_winerr.c This is the downport of 2009-09-11 22:26:35 +02:00
my_winfile.c WL#2360 Performance schema 2009-12-09 20:19:51 -07:00
my_winthread.c merge 2009-12-19 14:11:48 +01:00
my_write.c This is the downport of 2009-09-11 22:26:35 +02:00
mysys_priv.h merge 2010-01-11 17:46:16 +01:00
ptr_cmp.c WL#5105, review fix 2009-11-20 20:01:43 +01:00
queues.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
rijndael.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sha1.c Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
stacktrace.c Bug #52850: mysqld-debug.pdb doesn't match 2010-06-30 14:10:29 +02:00
string.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
test_charset.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
test_dir.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
test_fn.c Many files: 2006-12-23 20:17:15 +01:00
test_xml.c Many files: 2006-12-23 20:17:15 +01:00
testhash.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
thr_alarm.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
thr_lock.c A follow up patch for the fix for Bug#51263 "Deadlock between 2010-06-01 14:13:56 +04:00
thr_mutex.c WL#2360 Performance schema 2009-12-09 20:19:51 -07:00
thr_rwlock.c Fix for bug #51105 "MDL deadlock in rqg_mdl_stability test 2010-02-28 07:35:09 +03:00
tree.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
trie.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
typelib.c Fix C++ style comments, they cause syntax errors in C file. 2010-03-13 22:17:47 +01:00