Description:
main.partition_archive [ fail ] Found warnings/errors in server log file!
Test ended at 2009-02-18 09:45:31
file_name line
C:/cygwin/home/istruewing/bzrroot/mysql-6.0-bug38133-6/mysql-test/var/1/mysqld.1/mysqld.err Error: Freeing pointer out of range at line 399, '.\ha_archive.cc'
C:/cygwin/home/istruewing/bzrroot/mysql-6.0-bug38133-6/mysql-test/var/1/mysqld.1/mysqld.err Error: Freeing pointer out of range at line 399, '.\ha_archive.cc'
C:/cygwin/home/istruewing/bzrroot/mysql-6.0-bug38133-6/mysql-test/var/1/mysqld.1/mysqld.err Error: Freeing pointer out of range at line 399, '.\ha_archive.cc'
... (many of these follow)
^ Found warnings!!
ok
main.archive [ fail ] Found warnings/errors in server log file!
Test ended at 2009-02-18 09:59:42
file_name line
C:/cygwin/home/istruewing/bzrroot/mysql-6.0-bug38133-6/mysql-test/var/2/mysqld.1/mysqld.err Error: Freeing pointer out of range at line 399, '.\ha_archive.cc'
... (many of these follow)
main.archive_aio_posix [ fail ] Found warnings/errors in server log file!
Test ended at 2009-02-18 09:59:44
file_name line
C:/cygwin/home/istruewing/bzrroot/mysql-6.0-bug38133-6/mysql-test/var/1/mysqld.1/mysqld.err Error: Freeing unallocated data at line 399, '.\ha_archive.cc'
... (many of these follow)
main.archive_bitfield [ fail ] Found warnings/errors in server log file!
Test ended at 2009-02-18 10:00:10
file_name line
C:/cygwin/home/istruewing/bzrroot/mysql-6.0-bug38133-6/mysql-test/var/2/mysqld.1/mysqld.err Error: Freeing unallocated data at line 399, '.\ha_archive.cc'
... (many of these follow)
main.archive_gis [ fail ] Found warnings/errors in server log file!
Test ended at 2009-02-18 10:00:12
file_name line
C:/cygwin/home/istruewing/bzrroot/mysql-6.0-bug38133-6/mysql-test/var/1/mysqld.1/mysqld.err Error: Freeing unallocated data at line 399, '.\ha_archive.cc'
... (many of these follow)
main.mysqldump-max [ fail ] Found warnings/errors in server log file!
Test ended at 2009-02-18 10:43:23
file_name line
C:/cygwin/home/istruewing/bzrroot/mysql-6.0-bug38133-6/mysql-test/var/1/mysqld.1/mysqld.err Error: Freeing unallocated data at line 399, '.\ha_archive.cc'
^ Found warnings!!
ok
The offending line in ha_archive.cc is:
my_free((uchar*) share, MYF(0));
That's in free_share().
The share is allocated in get_share() at this line:
if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
&share, sizeof(*share),
&tmp_name, length+1,
NullS))
When running with --debug, the trace shows that the saher is allocated with my_malloc(), while it is freed with _myfree(), which is part of SAFEMALLOC. No wonder that it complains. It didn't record the allocation.
In the top-level CMakeLists.txt, we have this:
# Do not use SAFEMALLOC for Windows builds, as Debug CRT has the same functionality
# Neither SAFE_MUTEX works on Windows and it has been explicitely undefined in
# my_pthread.h
IF(NOT WIN32)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
ENDIF(NOT WIN32)
In storage/archive/CMakeLists.txt, we explicitly define SAFEMALLOC and SAFE_MUTEX. This is not a big problem, as long as all memory allocated by ARCHIVE is also freed by it and vice versa. my_malloc() and my_free() are macros that evaluate to _mymalloc() and _myfree() if SAFEMALLOC is defined. Other engines do also explicitly turn these on, whithout problems.
However, ha_archive.cc uses my_multi_malloc(), which is not redefined by SAFEMALLOC. It calls my_malloc() internally to do the final allocation. But since mysys is not compiled with SAFEMALLOC, it calls the real my_malloc().
How to repeat:
Make a debug build on Windows.
Run the mentioned tests.
Suggested fix:
=== modified file 'storage/archive/CMakeLists.txt'
--- storage/archive/CMakeLists.txt 2008-01-30 02:58:57 +0000
+++ storage/archive/CMakeLists.txt 2009-02-22 16:01:25 +0000
@@ -13,8 +13,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+#
+# NOTE: The use of my_multi_malloc() in ha_archive.cc excludes the
+# definition of SAFEMALLOC and SAFE_MUTEX here, as long as it is not
+# defined in the top-level CMakeList.txt. So do not define it here
+# explicitly, but inherit from the top-level file.
+#
+#SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+#SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
${CMAKE_SOURCE_DIR}/sql