From: | Aditya Gupta <adgupta1003(at)gmail(dot)com> |
---|---|
To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Unexpected Null Pointer For Static Shared Memory Segment |
Date: | 2024-07-27 16:58:14 |
Message-ID: | CH3PR10MB7834DBC41FA44C8844B7C5F9F1B52@CH3PR10MB7834.namprd10.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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. Thanks for your time and assistance!
Best,
Aditya Gupta
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Karlsson | 2024-07-27 19:03:20 | Re: tiny step toward threading: reduce dependence on setlocale() |
Previous Message | Dave Cramer | 2024-07-27 16:05:00 | Re: Protocol question regarding Portal vs Cursor |