mirror of
https://github.com/postgres/postgres.git
synced 2025-11-04 20:11:56 +03:00
Add Valgrind buffer access instrumentation.
Teach Valgrind memcheck to maintain the "defined-ness" of each shared
buffer based on whether the backend holds at least one pin at the point
it is accessed by access method code. Bugs like the one fixed by commit
b0229f26 can be detected using this new instrumentation.
Note that backends running with Valgrind naturally have their own
independent ideas about whether any given byte in shared memory is safe
or unsafe to access. There is no risk that concurrent access by
multiple backends to the same shared memory will confuse Valgrind's
instrumentation, because everything already works at the process level
(or at the memory mapping level, if you prefer).
Author: Álvaro Herrera, Peter Geoghegan
Reviewed-By: Anastasia Lubennikova
Discussion: https://postgr.es/m/20150723195349.GW5596@postgresql.org
Discussion: https://postgr.es/m/CAH2-WzkLgyN3zBvRZ1pkNJThC=xi_0gpWRUb_45eexLH1+k2_Q@mail.gmail.com
This commit is contained in:
@@ -269,12 +269,13 @@
|
||||
/*
|
||||
* 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.
|
||||
* memory errors that Valgrind would not detect on a vanilla build. It also
|
||||
* enables detection of buffer accesses that take place without holding a
|
||||
* buffer pin. See also src/tools/valgrind.supp.
|
||||
*
|
||||
* "make installcheck" is significantly slower under Valgrind. The client
|
||||
* requests fall in hot code paths, so USE_VALGRIND slows native execution by
|
||||
* a few percentage points even when not run under Valgrind.
|
||||
*
|
||||
* You should normally use MEMORY_CONTEXT_CHECKING with USE_VALGRIND;
|
||||
* instrumentation of repalloc() is inferior without it.
|
||||
|
||||
Reference in New Issue
Block a user