[PATCH] Memory leak in pg_config

From: Raúl Marín Rodríguez <rmrodriguez(at)carto(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] Memory leak in pg_config
Date: 2018-11-14 12:46:34
Message-ID: CAM6_UM6zi37N8rFUkyCu3PGG0_ta=0Go_BQmTXnJzqxGbbVUmw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I've been trying to run Postgis regress tests under Clang sanitizers and one of
the issues I'm facing is the constant stream of errors during the `configure`
step coming from calls to `pg_config`.

Example:
```
$ pg_config --cc
clang

=================================================================
==14521==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 368 byte(s) in 1 object(s) allocated from:
#0 0x55de20d161d9 in malloc (/usr/bin/pg_config+0xf81d9)
[...]

SUMMARY: AddressSanitizer: 2610 byte(s) leaked in 47 allocation(s).
```

The leaked memory is part of the `configdata` array which isn't freed before
exiting. It doesn't have any long term impact but it's annoying.

A similar thing happens in the `pg_config` SQL function. Since the memory
will be released at the end of the transaction, releasing it is optional but
I've done it anyway.

I'm attaching a the patch with the changes.

Greetings,

Greetings,

--
Raúl Marín Rodríguez
carto.com

Attachment Content-Type Size
configdata_leak-v1.patch text/x-patch 2.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message legrand legrand 2018-11-14 13:05:52 Re: proposal: simple query profile and tracing API
Previous Message Fabien COELHO 2018-11-14 12:17:19 Re: csv format for psql