Thread: BUG #18338: Memory leak in function 'dumpRule'

BUG #18338: Memory leak in function 'dumpRule'

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      18338
Logged by:          Jora
Email address:      jora.gevorgyan@rau.am
PostgreSQL version: 16.2
Operating system:   Ubuntu 20.04
Description:

The memory leak is found by a static analyzer developed at [CAST](
https://www.linkedin.com/company/cast-center/).

The memory alocated at [in qtabname]() is getting lost when function
[pg_fatal is

called](https://github.com/postgres/postgres/blob/09eb633e1baa3b7cd7929f3cc77f9c46f63c20b1/src/bin/pg_dump/pg_dump.c#L18007)


Re: BUG #18338: Memory leak in function 'dumpRule'

From
Daniel Gustafsson
Date:
> On 12 Feb 2024, at 14:36, PG Bug reporting form <noreply@postgresql.org> wrote:

> The memory leak is found by a static analyzer developed at [CAST](
> https://www.linkedin.com/company/cast-center/).

Seems like they have some more work to do on their product.

> The memory alocated at [in qtabname]() is getting lost when function
> [pg_fatal is
>
called](https://github.com/postgres/postgres/blob/09eb633e1baa3b7cd7929f3cc77f9c46f63c20b1/src/bin/pg_dump/pg_dump.c#L18007)

See src/include/common/logging.h: pg_fatal() calls exit(1), so there is no leak
here.

--
Daniel Gustafsson




Re: BUG #18338: Memory leak in function 'dumpRule'

From
Heikki Linnakangas
Date:
On 12/02/2024 15:36, PG Bug reporting form wrote:
> The memory leak is found by a static analyzer developed at [CAST](
> https://www.linkedin.com/company/cast-center/).
> 
> The memory alocated at [in qtabname]() is getting lost when function
> [pg_fatal is
>
called](https://github.com/postgres/postgres/blob/09eb633e1baa3b7cd7929f3cc77f9c46f63c20b1/src/bin/pg_dump/pg_dump.c#L18007)

No. pg_fatal() calls exit(1). It's not a leak when you exit the process; 
that will certainly release the memory.

There are hundreds of pg_fatal() calls in pg_dump, so I wonder why the 
tool picked on that one in particular. But it's not a bug.

-- 
Heikki Linnakangas
Neon (https://neon.tech)