Subject: Bug Report

From: [email-masked] ( Rowland Johnson )
Date: Wed, 29 Jan 92 16:04:42 -0800

We have transported Postgres v3.1 to run on an SGI. The only real bug
encountered is located in postmaster.c in the following area

	switch (status) {
	case STATUS_OK:
	  ConnStartup (port);
	  ActiveBackends = TRUE;
	  PortDestroy (port) ;
	  baseMask &= ~ port->mask;
	  ListDelete (curr) ;

PortDestroy ends with a call free(port). The problem is that with the
memory manager we are using the storage for port structure gets
compacted with something else. This causes the statement after the call
to PortDestroy to not work.  The correct sequence is 

	switch (status) {
	case STATUS_OK:
	  ConnStartup (port);
	  ActiveBackends = TRUE;
	  baseMask &= ~ port->mask;
	  PortDestroy (port) ;
	  ListDelete (curr) ;

The changes required to transport it the SGI have been documented if you
would like to have them.

Rowland R Johnson        [email-masked]
                         510-423-3064

---

From: postarch (Postgres Mailing Archive)
Date: Wed, 29 Jan 92 16:38:05 PST

you write:
> PortDestroy ends with a call free(port).  ...

Yeah, Neil McQuaige recently pointed this out to us as he discovered it 
while doing a SysV port.

Jeff Meredith
[email-masked]

---

From: U-E99999-Stephen Williams <[email-masked]>
Date: Thu, 30 Jan 92 8:27:54 EST

> [email-masked]
Could someone forward me any wisdom, bugs, etc. for a SysV port?

I have Postgres almost completely ported to ISC 386 Unix SysV3.2 Rel.3.

I have had the backend working perfectly (apparently, ran benchmarks, etc),
but have had severe trouble with the Postmaster.  The worst problem was
that when the above PortDestroy was called, the port was being closed
in the child also!!!  I think this is a bug in ISC TCP/IP (which is
really library layer on top of streams drivers/calls).  I commented out
the PortDestroy call for now (yes, I know I will run out of file 
descriptors eventually....)  I don't think the above change will
solve the problem, let me know if you disagree.  I checked port
by single stepping the frontend and postmaster and using netstat -a.

I now have the backend starting up correctly, with a socket, but it
still can't communicate to the frontend (it exits after a short time
with a 0 exit code, so no postmaster error...).

BTW, this was with 3.0 and I have just merged in 3.1 with my changes.
I will be back to debugging mode shortly.
Note that I am using gcc 1.40...

Thanks.
sdw
--
Stephen D. Williams     SDW Systems (513) 439-5428   GE AEG (513) 552-5237
ICBM: 39 34N 85 15W     Internet: [email-masked] CIS 76244,210
                        [email-masked]
Object Oriented R&D     By Horse: 10028 Village Tree Ct., Miamisburg, OH 45342