Skip site navigation (1) Skip section navigation (2)

Re: unchecked malloc

From: Sibtay Abbas <sibtay(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>,pgsql-hackers(at)postgresql(dot)org
Subject: Re: unchecked malloc
Date: 2005-09-27 12:09:45
Message-ID: bd6a355105092705093fb3f42b@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
This dicussion reminds me of a possible memory leak in plpgsql's code. In
case you are interested in it;

in pl_comp.c, plpgsql_build_variable takes a pointer to a PLpgSQL_type
structure, which is always a malloc'ed instance(since we always use
plpgsql_build_datatype function). The switch statement in
plpgsql_build_variable function elicits that its reference is only kept in
case the type structure represents a PLPGSQL_TTYPE_SCALAR, otherwise it is
not kept and needed in case its either PLPGSQL_TTYPE_ROW or
PLPGSQL_TTYPE_REC.

So is it intensional or a memory leak?

Thank you


On 9/27/05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu> writes:
> > "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote
> >> No, because you're thinking in terms of the backend environment, and
> >> generally in the backend the answer to "when to use malloc directly"
> >> is "never".
>
> > Well, except before MemoryContext mechanism is set up? For example, the
> > functions(e.g., GUC, vfd) used during bootstrap.
>
> I think you need to take another look at the startup sequences. Those
> modules are not run before MemoryContextInit. In any case, the odds
> of running out of memory before we get to MemoryContextInit are so small
> that I don't have a problem with crashing if it happens.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Responses

pgsql-hackers by date

Next:From: Chris BrowneDate: 2005-09-27 12:16:55
Subject: Re: State of support for back PG branches
Previous:From: Gnanavel SDate: 2005-09-27 12:05:58
Subject: Re: PostgreSQL overall design

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group