public inbox for [email protected]  
help / color / mirror / Atom feed
From: Aditya Gupta <[email protected]>
To: [email protected] <[email protected]>
Subject: Unexpected Null Pointer For Static Shared Memory Segment
Date: Sat, 27 Jul 2024 00:30:09 +0000
Message-ID: <CH3PR10MB7834D2B5AAA7C599DB321E17F1B52@CH3PR10MB7834.namprd10.prod.outlook.com> (raw)

Hello,

I hope this message finds you well. I am currently working on a PostgreSQL extension and have encountered an issue where a static pointer becomes null between different AM routines. My problem is as follows:

I am working with a few AM routines, specifically “ambuild” and “amrescan”. During “ambuild”, I use “ShmemInitStruct” to initialize a segment of shared memory and save the pointer to this location in my static, global pointer. I then set some values of the structure that the pointer points to, which I believe works correctly. I have ensured to acquire, and later release, the “AddinShmemInitLock” as well as check if we have found a segment of the same name in shared memory. I can access the pointer and any data I save in the struct perfectly fine during this AM routine.

When the extension later performs “amrescan”, the static pointer I had set is null. I am not quite sure why this is happening. I would greatly appreciate any guidance or suggestions! Perhaps I need to use the startup hooks when calling the “ShmemInitStruct” function (although I would like to avoid this as the size of the segment I am initializing varies at run time) or use dynamic shared memory?

Please let me know if there are any more details I can provide or if anything is unclear. This is my first time working on a PostgreSQL extension and asking a question using this mailing list, so please let me know if there is a more appropriate forum I should use.

Thanks for your time and assistance!

Best,
Aditya Gupta



reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Unexpected Null Pointer For Static Shared Memory Segment
  In-Reply-To: <CH3PR10MB7834D2B5AAA7C599DB321E17F1B52@CH3PR10MB7834.namprd10.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox