mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Cooperate with the Valgrind instrumentation framework.
Valgrind "client requests" in aset.c and mcxt.c teach Valgrind and its Memcheck tool about the PostgreSQL allocator. This makes Valgrind roughly as sensitive to memory errors involving palloc chunks as it is to memory errors involving malloc chunks. Further client requests in PageAddItem() and printtup() verify that all bits being added to a buffer page or furnished to an output function are predictably-defined. Those tests catch failures of C-language functions to fully initialize the bits of a Datum, which in turn stymie optimizations that rely on _equalConst(). Define the USE_VALGRIND symbol in pg_config_manual.h to enable these additions. An included "suppression file" silences nominal errors we don't plan to fix. Reviewed in earlier versions by Peter Geoghegan and Korry Douglas.
This commit is contained in:
34
src/include/utils/memdebug.h
Normal file
34
src/include/utils/memdebug.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* memdebug.h
|
||||
* Memory debugging support.
|
||||
*
|
||||
* Currently, this file either wraps <valgrind/memcheck.h> or substitutes
|
||||
* empty definitions for Valgrind client request macros we use.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/memdebug.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef MEMDEBUG_H
|
||||
#define MEMDEBUG_H
|
||||
|
||||
#ifdef USE_VALGRIND
|
||||
#include <valgrind/memcheck.h>
|
||||
#else
|
||||
#define VALGRIND_CHECK_MEM_IS_DEFINED(addr, size) do {} while (0)
|
||||
#define VALGRIND_CREATE_MEMPOOL(context, redzones, zeroed) do {} while (0)
|
||||
#define VALGRIND_DESTROY_MEMPOOL(context) do {} while (0)
|
||||
#define VALGRIND_MAKE_MEM_DEFINED(addr, size) do {} while (0)
|
||||
#define VALGRIND_MAKE_MEM_NOACCESS(addr, size) do {} while (0)
|
||||
#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size) do {} while (0)
|
||||
#define VALGRIND_MEMPOOL_ALLOC(context, addr, size) do {} while (0)
|
||||
#define VALGRIND_MEMPOOL_FREE(context, addr) do {} while (0)
|
||||
#define VALGRIND_MEMPOOL_CHANGE(context, optr, nptr, size) do {} while (0)
|
||||
#endif
|
||||
|
||||
#endif /* MEMDEBUG_H */
|
||||
Reference in New Issue
Block a user