Re: bug in SlabAlloc / VALGRIND_MAKE_MEM_DEFINED

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bug in SlabAlloc / VALGRIND_MAKE_MEM_DEFINED
Date: 2017-04-04 21:23:30
Message-ID: b4f6c2a3-df35-bd6e-5462-5dc333fa3da1@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
slab-valgrind-fix-v2.patch binary/octet-stream 886 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-04-04 21:46:28 Re: bug in SlabAlloc / VALGRIND_MAKE_MEM_DEFINED
Previous Message Keith Fiske 2017-04-04 21:22:14 Re: Adding support for Default partition in partitioning