7.4 shared memory error on 64-bit SPARC/Solaris 5.8

From: Thomas Baden <lindysandiego(at)yahoo(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: 7.4 shared memory error on 64-bit SPARC/Solaris 5.8
Date: 2003-11-19 03:17:44
Message-ID: 20031119031744.48639.qmail@web60507.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

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

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-11-19 05:06:08 Re: Make pg_dump dump conversions
Previous Message Bruce Momjian 2003-11-18 23:19:15 Re: SIGPIPE handling