Re: Fix some memory leaks in ecpg.addons

Поиск
Список
Период
Сортировка
От Tristan Partin
Тема Re: Fix some memory leaks in ecpg.addons
Дата
Msg-id CWTM35CAUKRT.1733OSMXUZW7@neon.tech
обсуждение исходный текст
Ответ на Re: Fix some memory leaks in ecpg.addons  (Michael Meskes <meskes@postgresql.org>)
Ответы Re: Fix some memory leaks in ecpg.addons  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Fix some memory leaks in ecpg.addons  (Alexander Lakhin <exclusion@gmail.com>)
Re: Fix some memory leaks in ecpg.addons  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On Wed Nov 8, 2023 at 11:18 AM CST, Michael Meskes wrote:
> Am Mittwoch, dem 08.11.2023 um 12:07 -0500 schrieb Tom Lane:
> > "Tristan Partin" <tristan@neon.tech> writes:
> > > clang and gcc both now support -fsanitize=address,undefined. These
> > > are
> > > really useful to me personally when trying to debug issues.
> > > Unfortunately ecpg code has a ton of memory leaks, which makes
> > > builds
> > > really painful. It would be great to fix all of them, but I don't
> > > have
> > > the patience to try to read flex/bison code. Here are two memory
> > > leak
> > > fixes in any case.
> >
> > I'm kind of failing to see the point.  As you say, the ecpg
> > preprocessor leaks memory like there's no tomorrow.  But given its
> > usage (process one source file and exit) I'm not sure that is worth
> > much effort to fix.  And what does it buy to fix just two spots?
>
> Agreed, it's not exactly uncommon for tools like ecpg to not worry
> about memory. After all it gets freed when the program ends.

In the default configuration of AddressSanitizer, I can't even complete
a full build of Postgres.

    meson setup build -Db_sanitize=address
    ninja -C build
    [1677/1855] Generating src/interfaces/ecpg/test/compat_informix/rfmtlong.c with a custom command
    FAILED: src/interfaces/ecpg/test/compat_informix/rfmtlong.c
    /home/tristan957/Projects/work/postgresql/build/src/interfaces/ecpg/preproc/ecpg --regression
-I../src/interfaces/ecpg/test/compat_informix-I../src/interfaces/ecpg/include/ -C INFORMIX -o
src/interfaces/ecpg/test/compat_informix/rfmtlong.c../src/interfaces/ecpg/test/compat_informix/rfmtlong.pgc 

    =================================================================
    ==114881==ERROR: LeakSanitizer: detected memory leaks

    Direct leak of 5 byte(s) in 1 object(s) allocated from:
        #0 0x7f88c34814a8 in strdup (/lib64/libasan.so.8+0x814a8) (BuildId: 6f17f87dc4c1aa9f9dde7c4856604c3a25ba4872)
        #1 0x4cfd93 in get_progname ../src/port/path.c:589
        #2 0x4b6dae in main ../src/interfaces/ecpg/preproc/ecpg.c:137
        #3 0x7f88c3246149 in __libc_start_call_main (/lib64/libc.so.6+0x28149) (BuildId:
651b2bed7ecaf18098a63b8f10299821749766e6)
        #4 0x7f88c324620a in __libc_start_main_impl (/lib64/libc.so.6+0x2820a) (BuildId:
651b2bed7ecaf18098a63b8f10299821749766e6)
        #5 0x402664 in _start
(/home/tristan957/Projects/work/postgresql/build/src/interfaces/ecpg/preproc/ecpg+0x402664)(BuildId:
fab06f774e305cbe628e03cdc22d935f7bb70a76)

    SUMMARY: AddressSanitizer: 5 byte(s) leaked in 1 allocation(s).
    ninja: build stopped: subcommand failed.

Are people using some suppression file or setting ASAN_OPTIONS to
something?

Here is a patch with a better solution.

--
Tristan Partin
Neon (https://neon.tech)

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: vignesh C
Дата:
Сообщение: Re: [PoC] pg_upgrade: allow to upgrade publisher node
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Version 14/15 documentation Section "Alter Default Privileges"