Re: 7.4 shared memory error on 64-bit SPARC/Solaris 5.8 - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: 7.4 shared memory error on 64-bit SPARC/Solaris 5.8
Date
Msg-id 200312012218.hB1MIVf09834@candle.pha.pa.us
Whole thread Raw
In response to 7.4 shared memory error on 64-bit SPARC/Solaris 5.8  (Thomas Baden <lindysandiego@yahoo.com>)
List pgsql-patches
We have applied a variant of this to CVS. Thanks.

---------------------------------------------------------------------------

Thomas Baden wrote:
> Hi there.  My install was failing the regression tests
> due to a shared memory error.
>
> I'm running Solaris 5.8, YASSP, and I am using the Sun
> Forte 7 compiler suite generating 64-bit code.
>
> I did some digging around, and it turns out that the
> IpcMemoryKey is a 64-bit number.  The source code uses
> uint32.  Changing this to a size_t fixes the problem
> under Solaris.  I don't know whether this would break
> other systems.  Anyway, here's the fix:
>
> I don't have the GNU diff, so please forgive the
> crudeness of the following.
>
> in file postgresql-7.4/src/backend/port/sysv_shmem.c,
> lines 42-48:
>   IpcMemoryKey UsedShmemSegID = 0;
>   void     *UsedShmemSegAddr = NULL;
>
> - static void *InternalIpcMemoryCreate(IpcMemoryKey
> memKey, uint32 size);
> + static void *InternalIpcMemoryCreate(IpcMemoryKey
> memKey, size_t size);
>   static void IpcMemoryDetach(int status, Datum
> shmaddr);
>   static void IpcMemoryDelete(int status, Datum
> shmId);
>   static PGShmemHeader
> *PGSharedMemoryAttach(IpcMemoryKey key,
>
> in file postgresql-7.4/src/backend/port/sysv_shmem.c,
> lines 62-68:
>    * print out an error and abort.  Other types of
> errors are not recoverable.
>    */
>   static void *
> - InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32
> size)
> + InternalIpcMemoryCreate(IpcMemoryKey memKey, size_t
> size)
>   {
>         IpcMemoryId shmid;
>         void       *memAddress;
>
> in file postgresql-7.4/src/backend/port/sysv_shmem.c,
> lines 234-240:
>    * zero will be passed.
>    */
>   PGShmemHeader *
> - PGSharedMemoryCreate(uint32 size, bool makePrivate,
> int port)
> + PGSharedMemoryCreate(size_t size, bool makePrivate,
> int port)
>   {
>         IpcMemoryKey NextShmemSegID;
>         void       *memAddress;
>
> in file postgresql-7.4/src/include/storage/pg_shmem.h,
> lines 24-30:
>   #ifndef PG_SHMEM_H
>   #define PG_SHMEM_H
>
> - typedef uint32 IpcMemoryKey;  /* shared memory key
> passed to shmget(2) */
> + typedef size_t IpcMemoryKey;  /* shared memory key
> passed to shmget(2) */
>
>   typedef struct PGShmemHeader  /* standard header for
> all Postgres shmem */
>   {
>
> in file postgresql-7.4/src/include/storage/pg_shmem.h,
> lines 41-47:
>   extern void *UsedShmemSegAddr;
>   #endif
>
> - extern PGShmemHeader *PGSharedMemoryCreate(uint32
> size, bool makePrivate,
> + extern PGShmemHeader *PGSharedMemoryCreate(size_t
> size, bool makePrivate,
>                                          int port);
>   extern bool PGSharedMemoryIsInUse(unsigned long id1,
> unsigned long id2);
>   extern void PGSharedMemoryDetach(void);
>
> Cheers,
> -Thomas
>
> __________________________________
> Do you Yahoo!?
> Protect your identity with Yahoo! Mail AddressGuard
> http://antispam.yahoo.com/whatsnewfree
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: export FUNC_MAX_ARGS as a read-only GUC variable
Next
From: Tom Lane
Date:
Subject: Re: 7.4 shared memory error on 64-bit SPARC/Solaris 5.8