Finding memory corruption in an extension - Mailing list pgsql-general

From Jack Orenstein
Subject Finding memory corruption in an extension
Date
Msg-id CAGNxcavzErZhb+7h6O33wBJOo1qVhTYGNRyC-j3ZydDaQJOy7w@mail.gmail.com
Whole thread Raw
Responses Re: Finding memory corruption in an extension  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
An extension I'm creating is causing Postgres to crash, almost certainly due to memory corruption.  I am using palloc0/pfree, calling SET_VARSIZE, and generally following the procedures documented here: https://www.postgresql.org/docs/12/xfunc-c.html. I am also testing my code outside of Postgres (using alloc/free instead of palloc0/pfree), and valgrind is not finding any corruption or leaks.

The crash is not completely reproducible, but when it does happen, it's pretty fast -- create a table, insert a couple of rows, explain a query. (My goal is to create a GIN index on my datatype, but this crash occurs without the index.)

I'm interested in advice on how to go about hunting down my problem. Something along the lines of a debugging malloc, or valgrind, for Postgres.

Jack Orenstein

pgsql-general by date:

Previous
From: Michael Lewis
Date:
Subject: Re: Suggestion: provide a "TRUNCATE PARTITION" command
Next
From: Pavel Stehule
Date:
Subject: Re: Finding memory corruption in an extension