Re: pg_dump vs malloc

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_dump vs malloc
Date: 2011-11-14 22:10:17
Message-ID: 201111142210.pAEMAH920036@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Excerpts from Magnus Hagander's message of mi jun 22 11:25:43 -0400 2011:
> > On Fri, Jun 10, 2011 at 21:07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > > Magnus Hagander <magnus(at)hagander(dot)net> writes:
> > >> I came across a situation today with a pretty bad crash of pg_dump,
> > >> due to not checking the return code from malloc(). When looking
> > >> through the code, it seems there are a *lot* of places in pg_dump that
> > >> doesn't check the malloc return code.
> > >
> > >> But we do have a pg_malloc() function in there - but from what I can
> > >> tell it's only used very sparsely?
> > >
> > >> Shouldn't we be using that one more or less everywhere
> > >
> > > Yup. Have at it.
> >
> > Something along the line of this?
>
> Huh, do you really need a new file for the four new functions? What's
> wrong with common.c?

I developed the attached patch to handle this. I moved the catalog code
from common.c into dumpcatalog.c, so there are just memory routines now
in common.c. I created new memory routines in pg_dumpall.c because
there is no AH structure in pg_dumpall.c. I then modified all the calls
to use the new routines, and removed the NULL return checks that were no
longer necessary.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/pg_dump text/x-diff 183.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ross Reedstrom 2011-11-14 22:16:02 Re: proposal: psql concise mode
Previous Message Thom Brown 2011-11-14 22:06:39 Re: Core Extensions relocation