bug in SlabAlloc / VALGRIND_MAKE_MEM_DEFINED
Hi,
Andres nagged to me about valgrind runs taking much longer since
9fab40ad introduced the SlabContext into reorderbuffer.c. And by
"longer" I mean hours instead of minutes.
After a bit of investigation I stumbled on this line in slab.c:
VALGRIND_MAKE_MEM_DEFINED(chunk, SlabChunkGetPointer(chunk));
which is wrong, because the second parameter should be size and not
another pointer. This essentially marks a lot of memory as defined,
which results in the extreme test runtime.
Instead, the line should be:
VALGRIND_MAKE_MEM_DEFINED(SlabChunkGetPointer(chunk), sizeof(int32));
Patch attached.
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
slab-valgrind-fix.patchbinary/octet-stream; name=slab-valgrind-fix.patchDownload
diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c
index d6be4fe..a542017 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);
On 04/04/2017 10:42 PM, Tomas Vondra wrote:
Hi,
Andres nagged to me about valgrind runs taking much longer since
9fab40ad introduced the SlabContext into reorderbuffer.c. And by
"longer" I mean hours instead of minutes.After a bit of investigation I stumbled on this line in slab.c:
VALGRIND_MAKE_MEM_DEFINED(chunk, SlabChunkGetPointer(chunk));
which is wrong, because the second parameter should be size and not
another pointer. This essentially marks a lot of memory as defined,
which results in the extreme test runtime.Instead, the line should be:
VALGRIND_MAKE_MEM_DEFINED(SlabChunkGetPointer(chunk), sizeof(int32));
Patch attached.
Turns out SlabCheck() was missing VALGRIND_MAKE_MEM_DEFINED, resulting
in a valgrind failure with --enable-assert. Updated patch version
attached, passing all tests in test_decoding.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
slab-valgrind-fix-v2.patchbinary/octet-stream; name=slab-valgrind-fix-v2.patchDownload
diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c
index d6be4fe..0fcfcb4 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);
}
On 2017-04-04 23:23:30 +0200, Tomas Vondra wrote:
On 04/04/2017 10:42 PM, Tomas Vondra wrote:
Hi,
Andres nagged to me about valgrind runs taking much longer since
9fab40ad introduced the SlabContext into reorderbuffer.c. And by
"longer" I mean hours instead of minutes.After a bit of investigation I stumbled on this line in slab.c:
VALGRIND_MAKE_MEM_DEFINED(chunk, SlabChunkGetPointer(chunk));
which is wrong, because the second parameter should be size and not
another pointer. This essentially marks a lot of memory as defined,
which results in the extreme test runtime.Instead, the line should be:
VALGRIND_MAKE_MEM_DEFINED(SlabChunkGetPointer(chunk), sizeof(int32));
Patch attached.
Turns out SlabCheck() was missing VALGRIND_MAKE_MEM_DEFINED, resulting in a
valgrind failure with --enable-assert. Updated patch version attached,
passing all tests in test_decoding.
Pushed, and re-enabled TestDecoding on skink.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers