mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +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:
@@ -206,6 +206,21 @@
|
||||
*------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include Valgrind "client requests", mostly in the memory allocator, so
|
||||
* Valgrind understands PostgreSQL memory contexts. This permits detecting
|
||||
* memory errors that Valgrind would not detect on a vanilla build. See also
|
||||
* src/tools/valgrind.supp. "make installcheck" runs 20-30x longer under
|
||||
* Valgrind. Note that USE_VALGRIND slowed older versions of Valgrind by an
|
||||
* additional order of magnitude; Valgrind 3.8.1 does not have this problem.
|
||||
* The client requests fall in hot code paths, so USE_VALGRIND also slows
|
||||
* native execution by a few percentage points.
|
||||
*
|
||||
* You should normally use MEMORY_CONTEXT_CHECKING with USE_VALGRIND;
|
||||
* instrumentation of repalloc() is inferior without it.
|
||||
*/
|
||||
/* #define USE_VALGRIND */
|
||||
|
||||
/*
|
||||
* Define this to cause pfree()'d memory to be cleared immediately, to
|
||||
* facilitate catching bugs that refer to already-freed values.
|
||||
@@ -218,9 +233,9 @@
|
||||
/*
|
||||
* Define this to check memory allocation errors (scribbling on more
|
||||
* bytes than were allocated). Right now, this gets defined
|
||||
* automatically if --enable-cassert.
|
||||
* automatically if --enable-cassert or USE_VALGRIND.
|
||||
*/
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
#if defined(USE_ASSERT_CHECKING) || defined(USE_VALGRIND)
|
||||
#define MEMORY_CONTEXT_CHECKING
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user