mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
Added macros to inform valgrind that memory is uninitialized
include/Makefile.am: Make my_valgrind.h global (as it's used by my_global.h) include/my_global.h: Include my_valgrind.h include/my_sys.h: TRASH() moved to my_valgrind.h include/my_valgrind.h: Add VALGRIND defines to mark memory mysys/my_alloc.c: Mark internal freed memory as undefined
This commit is contained in:
parent
2d43ff67dd
commit
9e23495b1d
5 changed files with 42 additions and 11 deletions
|
|
@ -23,7 +23,7 @@ HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \
|
|||
pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
|
||||
my_xml.h mysql_embed.h \
|
||||
my_pthread.h my_no_pthread.h \
|
||||
decimal.h errmsg.h my_global.h my_net.h \
|
||||
decimal.h errmsg.h my_global.h my_valgrind.h my_net.h \
|
||||
my_getopt.h sslopt-longopts.h my_dir.h \
|
||||
sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
|
||||
m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \
|
||||
|
|
|
|||
|
|
@ -566,18 +566,14 @@ int __void__;
|
|||
#define LINT_INIT(var)
|
||||
#endif
|
||||
|
||||
#include <my_valgrind.h>
|
||||
|
||||
#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_valgrind)
|
||||
#define VALGRIND_OR_LINT_INIT(var) var=0
|
||||
#else
|
||||
#define VALGRIND_OR_LINT_INIT(var)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_valgrind
|
||||
#define IF_VALGRIND(A,B) (A)
|
||||
#else
|
||||
#define IF_VALGRIND(A,B) (B)
|
||||
#endif
|
||||
|
||||
/*
|
||||
Suppress uninitialized variable warning without generating code.
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,6 @@ extern int NEAR my_errno; /* Last error in mysys */
|
|||
#define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C)
|
||||
#define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C)
|
||||
#define my_strndup(A,B,C) _my_strndup((A),(B),__FILE__,__LINE__,C)
|
||||
|
||||
#define QUICK_SAFEMALLOC sf_malloc_quick=1
|
||||
#define NORMAL_SAFEMALLOC sf_malloc_quick=0
|
||||
extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
|
||||
|
|
@ -173,7 +172,6 @@ extern char *my_strndup(const char *from, size_t length,
|
|||
#define CALLER_INFO_PROTO /* nothing */
|
||||
#define CALLER_INFO /* nothing */
|
||||
#define ORIG_CALLER_INFO /* nothing */
|
||||
#define TRASH(A,B) /* nothing */
|
||||
#endif
|
||||
|
||||
#if defined(ENABLED_DEBUG_SYNC)
|
||||
|
|
|
|||
38
include/my_valgrind.h
Normal file
38
include/my_valgrind.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* Copyright (C) 2010 Monty Program Ab
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
|
||||
/* Some defines to make it easier to use valgrind */
|
||||
|
||||
#ifdef HAVE_valgrind
|
||||
#define IF_VALGRIND(A,B) (A)
|
||||
#else
|
||||
#define IF_VALGRIND(A,B) (B)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_valgrind)&& defined(HAVE_VALGRIND_MEMCHECK_H)
|
||||
#include <valgrind/memcheck.h>
|
||||
#else
|
||||
#define VALGRIND_MAKE_MEM_DEFINED(addr, size) do { } while(0)
|
||||
#define VALGRIND_MAKE_MEM_NOACCESS(addr, size) do { } while(0)
|
||||
#ifdef SAFEMALLOC
|
||||
#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size) bfill(addr, size, 0x8F)
|
||||
#else
|
||||
#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size) do { } while(0)
|
||||
#endif /* SAFEMALLOC */
|
||||
#endif /* HAVE_valgrind */
|
||||
|
||||
/* Compatibility with old source */
|
||||
#define TRASH(A,B) VALGRIND_MAKE_MEM_UNDEFINED(A, B)
|
||||
|
|
@ -21,7 +21,6 @@
|
|||
#undef EXTRA_DEBUG
|
||||
#define EXTRA_DEBUG
|
||||
|
||||
|
||||
/*
|
||||
Initialize memory root
|
||||
|
||||
|
|
@ -276,7 +275,7 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
|
|||
DBUG_RETURN((void*) start);
|
||||
}
|
||||
|
||||
#define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left)
|
||||
#define TRASH_MEM(X) VALGRIND_MAKE_MEM_UNDEFINED(((char*)(X) + ((X)->size-(X)->left)), (X)->left)
|
||||
|
||||
/* Mark all data in blocks free for reusage */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue