From: | Stephen Frost <sfrost(at)snowman(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Pavel Raiskup <praiskup(at)redhat(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: minor leaks in pg_dump (PG tarball 10.6) |
Date: | 2018-12-05 17:38:08 |
Message-ID: | 20181205173808.GG3415@tamriel.snowman.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Greetings,
* Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> Stephen Frost <sfrost(at)snowman(dot)net> writes:
> > * Pavel Raiskup (praiskup(at)redhat(dot)com) wrote:
> >> - attrdefs = (AttrDefInfo *) pg_malloc(numDefaults * sizeof(AttrDefInfo));
> >> ...
> >> + attrdefs = (AttrDefInfo *) pg_malloc(numDefaults * sizeof(AttrDefInfo));
>
> > This change doesn't seem to make any sense to me..? If anything, seems
> > like we'd end up overallocating memory *after* this change, where we
> > don't today (though an analyzer tool might complain because we don't
> > free the memory from it and instead copy the pointer from each of these
> > items into the tbinfo structure).
>
> Yeah, Coverity is exceedingly not smart about the method pg_dump uses
> (in lots of places, not just here) of allocating an array and then
> entering pointers to individual array elements into its long-lived
> data structures. I concur that the proposed change is giving up a
> lot of malloc overhead to silence an invalid complaint, and we
> shouldn't do it.
Agreed, patch attached. If there aren't any more comments, I'll plan to
push this later today or tomorrow. I wasn't thinking we would backpatch
this, so if others feel differently, please let me know.
> The other two points seem probably valid, so I wonder why our own
> Coverity runs haven't noticed them.
Not sure.. Looks like Coverity (incorrectly) worries about srvname
being NULL and then dereferenced inside fmtId(), except that relkind
doesn't change between the switch() and the conditional where srvname is
used. Maybe that is masking the resource leak concern? I don't see it
complaining about ftoptions though, so really not sure what's going on
there. I can try to ask the Coverity admin folks, but they've yet to
respond to multiple requests I've made about linking in the v11 branch
with the others..
Thanks!
Stephen
Attachment | Content-Type | Size |
---|---|---|
fix-pg_dump-memory-leak_v1.patch | text/x-diff | 2.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2018-12-05 17:49:57 | Re: proposal: plpgsql pragma statement |
Previous Message | Tom Lane | 2018-12-05 17:24:54 | Re: slow queries over information schema.tables |