pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Tomas Vondra <tv@fuzzy.cz>
Cc: pgsql-hackers@postgresql.org
Subject: Re: SlabCheck leaks memory into TopMemoryContext
Date: Thu, 16 Jan 2020 14:46:52 +0100
Message-ID: <20200116134652.3myxa6rgo652oovk@development> (raw)
In-Reply-To: <20200116064143.opcu2vhcktddpzbh@alap3.anarazel.de>
References: <20200116044119.g45f7pmgz4jmodxj@alap3.anarazel.de>
	<23952.1579151393@sss.pgh.pa.us>
	<20200116061732.vvpyexenaortpu5y@alap3.anarazel.de>
	<27213.1579155900@sss.pgh.pa.us>
	<20200116064143.opcu2vhcktddpzbh@alap3.anarazel.de>

On Wed, Jan 15, 2020 at 10:41:43PM -0800, Andres Freund wrote:
>Hi,
>
>On 2020-01-16 01:25:00 -0500, Tom Lane wrote:
>> Andres Freund <andres@anarazel.de> writes:
>> > On 2020-01-16 00:09:53 -0500, Tom Lane wrote:
>> >> It's basically assuming that the memory management mechanism is sane,
>> >> which makes the whole thing fundamentally circular, even if it's
>> >> relying on some other context to be sane.  Is there a way to do the
>> >> checking without extra allocations?
>>
>> > Probably not easily.
>>
>> In the AllocSet code, we don't hesitate to expend extra space per-chunk
>> for debug support:
>>
>> typedef struct AllocChunkData
>> {
>> ...
>> #ifdef MEMORY_CONTEXT_CHECKING
>> 	Size		requested_size;
>> #endif
>> ...
>>
>> I don't see a pressing reason why SlabContext couldn't do something
>> similar, either per-chunk or per-context, whatever makes sense.
>
>Well, what I suggested upthread, was to just have two globals like
>
>int slabcheck_freechunks_size;
>bool *slabcheck_freechunks;
>
>and realloc that to the larger size in SlabContextCreate() if necessary,
>based on the computed chunksPerBlock?  I thought you were asking whether
>any additional memory could just be avoided...
>

I don't see why not to just do what Tom proposed, i.e. allocate this as
part of the memory context in SlabContextCreate(), when memory context
checking is enabled. It seems much more convenient / simpler than the
globals (no repalloc, ...).


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





view thread (20+ messages)  latest in thread

Message-ID: <20200116134652.3myxa6rgo652oovk@development>
Permalink:  ../20200116134652.3myxa6rgo652oovk@development/
Also on:    postgresql.org/message-id/20200116134652.3myxa6rgo652oovk@development

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tomas.vondra@2ndquadrant.com, andres@anarazel.de, tgl@sss.pgh.pa.us, tv@fuzzy.cz
  Subject: Re: SlabCheck leaks memory into TopMemoryContext
  In-Reply-To: <20200116134652.3myxa6rgo652oovk@development>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox