Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.551.2.1
diff -c -p -r1.551.2.1 postmaster.c
*** src/backend/postmaster/postmaster.c	27 Jun 2008 01:53:31 -0000	1.551.2.1
--- src/backend/postmaster/postmaster.c	6 Apr 2009 23:14:00 -0000
*************** BackendStartup(Port *port)
*** 2774,2779 ****
--- 2774,2780 ----
  {
  	Backend    *bn;				/* for backend cleanup */
  	pid_t		pid;
+ 	Dlelem	   *newel;
  
  	/*
  	 * Compute the cancel key that will be assigned to this backend. The
*************** BackendStartup(Port *port)
*** 2794,2799 ****
--- 2795,2818 ----
  				 errmsg("out of memory")));
  		return STATUS_ERROR;
  	}
+ 	PG_TRY();
+ 	{
+ 		newel = DLNewElem(bn);
+ 		elog(ERROR, "out of luck :-(");
+ 	}
+ 	PG_CATCH();
+ 	{
+ 		/*
+ 		 * it would be great if we could just reduce the error severity of the
+ 		 * current error
+ 		 */
+ 		FlushErrorState();
+ 		ereport(LOG,
+ 				(errcode(ERRCODE_OUT_OF_MEMORY),
+ 				 errmsg("out of memory")));
+ 		return STATUS_ERROR;
+ 	}
+ 	PG_END_TRY();
  
  	/* Pass down canAcceptConnections state (kluge for EXEC_BACKEND case) */
  	port->canAcceptConnections = canAcceptConnections();
*************** BackendStartup(Port *port)
*** 2857,2863 ****
  	bn->cancel_key = MyCancelKey;
  	bn->is_autovacuum = false;
  	bn->dead_end = (port->canAcceptConnections != CAC_OK);
! 	DLAddHead(BackendList, DLNewElem(bn));
  #ifdef EXEC_BACKEND
  	if (!bn->dead_end)
  		ShmemBackendArrayAdd(bn);
--- 2876,2883 ----
  	bn->cancel_key = MyCancelKey;
  	bn->is_autovacuum = false;
  	bn->dead_end = (port->canAcceptConnections != CAC_OK);
! 
! 	DLAddHead(BackendList, newel);
  #ifdef EXEC_BACKEND
  	if (!bn->dead_end)
  		ShmemBackendArrayAdd(bn);
