Valgrind - showing memory leaks?

From: Yasir <yasir(dot)hussain(dot)shah(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Valgrind - showing memory leaks?
Date: 2025-05-08 08:04:57
Message-ID: CAA9OW9e536dJanVKZRd_GKQ4wN_m5rhsMnrL6ZvaWagzLwv3=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

I ran a postgres server with valgrind looking for memory leaks at a
particular extension, but I am experiencing something strange. Here are the
steps:

1. PG configured & compile as follows:
---------------------------------------------------
$ ./configure --enable-debug CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer"
--enable-cassert \
--enable-rpath --enable-tap-tests --with-ssl=openssl --with-systemd
--enable-depend \
--enable-injection-points --with-liburing --enable-dtrace --prefix=/tmp/pg18
$ make install

2. In terminal-1, PG Server launched as follows:
----------------------------------------------------------------
$ valgrind --leak-check=full --gen-suppressions=all
--suppressions=postgres/src/tools/valgrind.supp \
--time-stamp=yes
--error-markers=VALGRINDERROR-BEGIN,VALGRINDERROR-END
--log-file=/valgrind_%p.log
\
--trace-children=yes /tmp/pg18/bin/postgres -D /tmp/data1
--log_line_prefix="%m %p " \
--log_statement=all --shared_buffers=64MB 2>&1 | tee
/tmp/valgrind_postmaster.log

3. In terminal-2, psql launched as follows:
-------------------------------------------------------
$ /tmp/pg18/bin/psql postgres
psql (18devel)
Type "help" for help.

postgres=# select pg_backend_pid();
pg_backend_pid
----------------
2293900
(1 row)

postgres=# CREATE TABLE tbl1 (scope text NOT NULL);
CREATE TABLE
postgres=# INSERT INTO tbl1 VALUES ('some'),('full');
INSERT 0 2
postgres=# select * from tbl1;
scope
-------
some
full
(2 rows)

postgres=# drop table tbl1;
DROP TABLE
postgres=# \q

Attached is valgrind output generated showing memory leaks.

5. Question:
----------------
I believe that the valgrind should not report any memory leaks in such
simple/common commands. What am I doing wrong here?

Regards,

Yasir Hussain
Data Bene

Attachment Content-Type Size
valgrind_2293900.log text/x-log 227.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yasir 2025-05-08 08:08:20 Valgrind - showing memory leaks
Previous Message jian he 2025-05-08 07:45:00 Re: PG 18 release notes draft committed