Subject: palloc, pfree / POSTGRES and GNU gcc

From: SEP Lutz <[email-masked]>
Date: Tue, 17 Nov 92 02:00:34 -0800

Hello there,

we are using POSTGRES 4.0.1 on a SUN SPARCstation (SUN OS 4.1.1) to build
up a project database application.

We decided to use ANSI-C style and the GNU gcc (Version 1.40) to do the
programming, but ran into severe memory management problems when freeing
malloced (palloced) memory, which seem to result from incompabilities
in memory management between cc (with which POSTGRES is compiled - we used
the standard Make install), and gcc:

When trying to pfree memory palloced for user-defined query strings by our
(gcc compiled) application, not only the memory we wanted to free, but
also totally different blocks of memory allocated by (SUN-cc-compiled)
POSTGRES itself - such as PortalBuffers - get freed, which causes
libpq portal functions to return wrong data or crash with segmentation faults.

What can we do to solve this problem?

1) Is it possible to use gcc to build up POSTGRES and how can we do so?
   [ We tried to change all the cc-calls in the makefiles into gcc,
   and got no errors during compiling, but the gcc-compiled postgres
   backend runs into a "semctl: Bad address" error. ]

2) If not, are there any other possibilities to prevent the
   memory allocating problems, except using cc to compile our application
   (and change all function prototypes and definitions into old
   K&R-style)? [ SUN's acc is not available here. ]

Thank you in advance,

Gesamic project group