Valgrind mem-check for postgres extension

From: Natarajan R <nataraj3098(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Valgrind mem-check for postgres extension
Date: 2022-05-18 04:43:04
Message-ID: CAPqxBt7+yyVV91J+=RnqeN_YpH2=gsD=+JLedvKLstEUTU9Biw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi pg-hackers,

I have written a postgres extension, and know that memory leak check can be
done with valgrind. With the help of postgres_valgrind_wiki
<https://wiki.postgresql.org/wiki/Valgrind> started postgres server with
the valgrind(as given in the wiki)

valgrind --leak-check=no --gen-suppressions=all \
--suppressions=src/tools/valgrind.supp --time-stamp=yes \
--error-markers=VALGRINDERROR-BEGIN,VALGRIND ERROR-END \
--log-file=$HOME/pg-valgrind/%p.log --trace-children=yes \
postgres --log_line_prefix="%m %p " \
--log_statement=all --shared_buffers=64MB 2>&1 | tee
$HOME/pg-valgrind/postmaster.log

I have few doubts in here,

1. When I run with *--leak-check=full*, I get memory leaks for postgres
functions under possibly or definitely lost categories.. Is this expected?
If yes, how shall i ignore it?(by creating .supp?).. kindly suggest
2. Is there any other way to test my extension memory leaks alone, because
combining with postgres leaks is making instrumentation complex?..
3. I have seen some macros for valgrind support within postgres source code
under utils/memdebug.h, but couldn't get complete idea of using it from the
comments in pg_config_manual.h under *USE_VALGRIND *macro, pls provide some
guidance here..

Thank you,
Natarajan R

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-05-18 04:59:30 Re: Handle infinite recursion in logical replication setup
Previous Message shiy.fnst@fujitsu.com 2022-05-18 03:00:38 RE: Skipping schema changes in publication