summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2017-04-04 21:26:42 +0000
committerAndres Freund2017-04-04 21:26:42 +0000
commit490e9a98ff964df95311e2b5a68a15f63bce0cfd (patch)
tree7c9753b5bd514018aca3c3d6f25cb5d9eaac9d0a
parente75a78656bcaa3faff6b85891ca69d45dd21023f (diff)
Fix two valgrind issues in slab allocator.
During allocation VALGRIND_MAKE_MEM_DEFINED was called with a pointer as size. That kind of works, but makes valgrind exceedingly slow for workloads involving the slab allocator. Secondly there was an access to memory marked as unreachable within SlabCheck(). Fix that too. Author: Tomas Vondra Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/backend/utils/mmgr/slab.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c
index d6be4fe660..0fcfcb4c78 100644
--- a/src/backend/utils/mmgr/slab.c
+++ b/src/backend/utils/mmgr/slab.c
@@ -403,7 +403,7 @@ SlabAlloc(MemoryContext context, Size size)
* Remove the chunk from the freelist head. The index of the next free
* chunk is stored in the chunk itself.
*/
- VALGRIND_MAKE_MEM_DEFINED(chunk, SlabChunkGetPointer(chunk));
+ VALGRIND_MAKE_MEM_DEFINED(SlabChunkGetPointer(chunk), sizeof(int32));
block->firstFreeChunk = *(int32 *) SlabChunkGetPointer(chunk);
Assert(block->firstFreeChunk >= 0);
@@ -725,6 +725,7 @@ SlabCheck(MemoryContext context)
/* read index of the next free chunk */
chunk = SlabBlockGetChunk(slab, block, idx);
+ VALGRIND_MAKE_MEM_DEFINED(SlabChunkGetPointer(chunk), sizeof(int32));
idx = *(int32 *) SlabChunkGetPointer(chunk);
}