From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jack Orenstein <jao@geophile.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Static memory, shared memory
Date: Sat, 09 Jan 2021 12:17:59 -0500
Message-ID: <400232.1610212679@sss.pgh.pa.us> (raw)
In-Reply-To: <CAGNxcatnDTS8gnuz5s++Qn8o3-No+BCMxBaZwOEija-t0O=4PQ@mail.gmail.com>
References: <CAGNxcatnDTS8gnuz5s++Qn8o3-No+BCMxBaZwOEija-t0O=4PQ@mail.gmail.com>
Jack Orenstein <jao@geophile.com> writes:
> I am writing a Postgres extension, and thought that I had memory
> corruption, (thanks for the --enable-cassert lead). I might, but It now
> looks like I need to understand the use of shared memory and locking in
> Postgres. So I have two questions.
> 1) I am now guessing that my original problem is caused by relying on
> static memory in my extension (i.e., in the source declaring
> PG_MODULE_MAGIC). This static memory is almost but not quite constant -- it
> is initialized from _PG_init, and then never modified. I suspect that this
> cannot work in general (since Postgres is multi-process), but I thought it
> would be adequate for early development. However, I am seeing this static
> memory get corrupted even when there is only a single process executing the
> extension code (verified by examining getpid()).
Define what you mean by "corrupted". It seems highly unlikely that any
code but your own is touching this memory.
Really the big-picture question here is what are you hoping to accomplish
and why do you think this memory might need to be shared?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, jao@geophile.com
Subject: Re: Static memory, shared memory
In-Reply-To: <400232.1610212679@sss.pgh.pa.us>
References: <CAGNxcatnDTS8gnuz5s++Qn8o3-No+BCMxBaZwOEija-t0O=4PQ@mail.gmail.com> <400232.1610212679@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox