[comp.soft-sys.andrew] Fixes for X server memory leaks.

wdc@ATHENA.MIT.EDU (Bill Cattey) (03/22/90)

Forgive this large posting to the whole group, but having been in the
position of debugging X servers, I appreciate the need to WIDELY
publicise bug fixes.

Todd:  Your work in finding the leak has not been wasted!  I showed your
message around to my friends here and they saw this on the fix-trackers
mailing list and forwarded it to me.

Lookey lookey!  A whole slew of memory leaks plugged in the server.

Share and enjoy,

-wdc

Received: by E40-PO.MIT.EDU (5.45/4.7) id AA10886; Wed, 21 Mar 90 23:09:23 EST
Received: from ACHATES.MIT.EDU by ATHENA.MIT.EDU with SMTP
	id AA13225; Wed, 21 Mar 90 23:09:20 EST
Received: by ACHATES.MIT.EDU (5.61) id AA00828; Wed, 21 Mar 90 23:03:35 -0500
Message-Id: <9003220403.AA00828@ACHATES.MIT.EDU>
To: wdc@ATHENA.MIT.EDU
Subject: (seq: 775) close XBUG #2765:  server memory leak
Date: Wed, 21 Mar 90 23:03:34 EST
From: John Carr <jfc@ATHENA.MIT.EDU>


[0684]  daemon@ATHENA.MIT.EDU X11R4_Server_Development 03/21/90 10:34 (318 lines)
Subject: (seq: 775) close XBUG #2765:  server memory leak
To: fix-trackers@expo.lcs.mit.edu
Date: Wed, 21 Mar 90 10:30:37 -0500
From: rws@expo.lcs.mit.edu (Bob Scheifler)

### bug number:   2765
### area:         server
### severity:     medium high
### comments:     

Files:	server/ddx/mfb/mfbgc.c
	server/ddx/cfb/cfbgc.c
	server/ddx/apollo/apc/apcgc.c
	server/ddx/dec/qdss/qdgc.c
	server/ddx/ibm/aed/aedGC.c
	server/ddx/ibm/apa16/apa16GC.c

*** /tmp/,RCSt1a03549	Wed Mar 21 10:20:49 1990
--- server/ddx/mfb/mfbgc.c	Tue Mar 20 14:49:16 1990
***************
*** 21,27 ****
  SOFTWARE.
  
  ******************************************************************/
! /* $XConsortium: mfbgc.c,v 5.18 89/11/29 19:53:27 rws Exp $ */
  #include "X.h"
  #include "Xmd.h"
  #include "Xproto.h"
--- 21,27 ----
  SOFTWARE.
  
  ******************************************************************/
! /* $XConsortium: mfbgc.c,v 5.19 90/03/20 14:48:59 rws Exp $ */
  #include "X.h"
  #include "Xmd.h"
  #include "Xproto.h"
***************
*** 420,441 ****
      Mask 	changes;
      GCPtr	pGCDst;
  {
!     RegionPtr		pClip;
! 
!     if(changes & GCClipMask)
!     {
! 	if(pGCDst->clientClipType == CT_PIXMAP)
! 	{
! 	    ((PixmapPtr)pGCDst->clientClip)->refcnt++;
! 	}
! 	else if(pGCDst->clientClipType == CT_REGION)
! 	{
! 	    pClip = (RegionPtr) pGCDst->clientClip;
! 	    pGCDst->clientClip =
! 	        (pointer)(* pGCDst->pScreen->RegionCreate)(NULL, 1);
! 	    (* pGCDst->pScreen->RegionCopy)(pGCDst->clientClip, pClip);
! 	}
!     }
  }
  
  void
--- 420,426 ----
      Mask 	changes;
      GCPtr	pGCDst;
  {
!     return;
  }
  
  void

*** /tmp/,RCSt1a03563	Wed Mar 21 10:21:35 1990
--- server/ddx/cfb/cfbgc.c	Wed Mar 21 10:21:38 1990
***************
*** 22,28 ****
  
  ******************************************************************/
  
! /* $XConsortium: cfbgc.c,v 5.32 89/11/29 19:53:03 rws Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 22,28 ----
  
  ******************************************************************/
  
! /* $XConsortium: cfbgc.c,v 5.32.1.1 90/03/21 10:16:47 rws Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 798,824 ****
      Mask 	changes;
      GCPtr	pGCDst;
  {
!     RegionPtr		pClip;
! 
!     if(changes & GCClipMask)
!     {
! 	if(pGCDst->clientClipType == CT_PIXMAP)
! 	{
! 	    ((PixmapPtr)pGCDst->clientClip)->refcnt++;
! 	}
! 	else if(pGCDst->clientClipType == CT_REGION)
! 	{
! 	    BoxRec pixbounds;
! 
! 	    pixbounds.x1 = 0;
! 	    pixbounds.y1 = 0;
! 	    pixbounds.x2 = 0;
! 	    pixbounds.y2 = 0;
! 
! 	    pClip = (RegionPtr) pGCDst->clientClip;
! 	    pGCDst->clientClip =
! 	        (pointer)(* pGCDst->pScreen->RegionCreate)(&pixbounds, 1);
! 	    (* pGCDst->pScreen->RegionCopy)(pGCDst->clientClip, pClip);
! 	}
!     }
  }
--- 798,802 ----
      Mask 	changes;
      GCPtr	pGCDst;
  {
!     return;
  }

*** /tmp/,RCSt1a03579	Wed Mar 21 10:23:04 1990
--- server/ddx/apollo/apc/apcgc.c	Wed Mar 21 09:59:01 1990
***************
*** 25,31 ****
  University of California.
  ******************************************************************/
  
! /* $XConsortium: apcgc.c,v 1.3 90/02/22 10:43:29 rws Exp $ */
  
  #include "apc.h"
  #include "Xmd.h"
--- 25,31 ----
  University of California.
  ******************************************************************/
  
! /* $XConsortium: apcgc.c,v 1.4 90/03/21 09:58:39 rws Exp $ */
  
  #include "apc.h"
  #include "Xmd.h"
***************
*** 132,138 ****
  
  /*
   * apcCopyGC -- DDX interface (GC "funcs")
!  *      Copy client clip info when copying a GC.
   */
  static void
  apcCopyGC (pGCSrc, changes, pGCDst)
--- 132,138 ----
  
  /*
   * apcCopyGC -- DDX interface (GC "funcs")
!  *	Nothing to do.
   */
  static void
  apcCopyGC (pGCSrc, changes, pGCDst)
***************
*** 140,160 ****
      Mask    changes;
      GCPtr   pGCDst;
  {
-     RegionPtr   pClip;
- 
-     if (changes & GCClipMask)
-     {
-         if (pGCDst->clientClipType == CT_PIXMAP)
-         {
-             ((PixmapPtr)pGCDst->clientClip)->refcnt++;
-         }
-         else if (pGCDst->clientClipType == CT_REGION)
-         {
-             pClip = (RegionPtr) pGCDst->clientClip;
-             pGCDst->clientClip = (pointer)(* pGCDst->pScreen->RegionCreate)(NULL, 1);
-             (* pGCDst->pScreen->RegionCopy)(pGCDst->clientClip, pClip);
-         }
-     }
  }
  
  /*
--- 140,145 ----

*** /tmp/,RCSt1a03598	Wed Mar 21 10:24:21 1990
--- server/ddx/dec/qdss/qdgc.c	Wed Mar 21 10:03:20 1990
***************
*** 358,375 ****
      int                 maskQ;
      GCPtr		pgcSrc;
  {
! #ifdef X11R4
!     if (maskQ & GCClipMask) {
! 	if (pgcDst->clientClipType == CT_PIXMAP)
! 	    ((PixmapPtr)pgcDst->clientClip)->refcnt++;
! 	else if (pgcDst->clientClipType == CT_REGION) {
! 	    RegionPtr pClip = (RegionPtr) pgcDst->clientClip;
! 	    pgcDst->clientClip =
! 		(pointer)(* pgcDst->pScreen->RegionCreate)(NULL, 1);
! 	    (* pgcDst->pScreen->RegionCopy)(pgcDst->clientClip, pClip);
! 	}
!     }
! #else
      RegionPtr		pregionsrc = (RegionPtr) pgcSrc->clientClip;
  
      if ( ! (maskQ & GCClipMask)
--- 358,364 ----
      int                 maskQ;
      GCPtr		pgcSrc;
  {
! #ifndef X11R4
      RegionPtr		pregionsrc = (RegionPtr) pgcSrc->clientClip;
  
      if ( ! (maskQ & GCClipMask)

*** /tmp/,RCSt1a03602	Wed Nov 29 16:33:34 1989
--- server/ddx/ibm/aed/aedGC.c	Wed Mar 21 09:55:11 1990
***************
*** 43,49 ****
  SOFTWARE.
  
  ******************************************************************/
! /* $Header: /afs/testers.athena.mit.edu/src/x11r4/src/mit/server/ddx/ibm/aed/RCS/aedGC.c,v 1.3 89/11/29 16:26:40 jfc Exp Locker: jfc $ */
  #include "X.h"
  #include "Xproto.h"
  #include "Xmd.h"
--- 43,49 ----
  SOFTWARE.
  
  ******************************************************************/
! /* $XConsortium: aedGC.c,v 1.4 90/03/21 09:54:58 rws Exp $ */
  #include "X.h"
  #include "Xproto.h"
  #include "Xmd.h"
***************
*** 267,288 ****
      Mask 	changes;
      GCPtr	pGCDst;
  {
!     RegionPtr		pClip;
! 
!     if(changes & GCClipMask)
!     {
! 	if(pGCDst->clientClipType == CT_PIXMAP)
! 	{
! 	    ((PixmapPtr)pGCDst->clientClip)->refcnt++;
! 	}
! 	else if(pGCDst->clientClipType == CT_REGION)
! 	{
! 	    pClip = (RegionPtr) pGCDst->clientClip;
! 	    pGCDst->clientClip =
! 	        (pointer)(* pGCDst->pScreen->RegionCreate)(NULL, 1);
! 	    (* pGCDst->pScreen->RegionCopy)(pGCDst->clientClip, pClip);
! 	}
!     }
  }
  
  struct commonOps {
--- 267,273 ----
      Mask 	changes;
      GCPtr	pGCDst;
  {
!     return;
  }
  
  struct commonOps {

*** /tmp/,RCSt1a03623	Wed Mar 21 10:26:47 1990
--- server/ddx/ibm/apa16/apa16GC.c	Wed Mar 21 09:50:35 1990
***************
*** 66,72 ****
  SOFTWARE.
  
  ******************************************************************/
! /* $XConsortium: apa16GC.c,v 1.2 90/03/05 13:53:33 swick Exp $ */
  #include "X.h"
  #include "Xmd.h"
  #include "Xproto.h"
--- 66,72 ----
  SOFTWARE.
  
  ******************************************************************/
! /* $XConsortium: apa16GC.c,v 1.3 90/03/21 09:50:21 rws Exp $ */
  #include "X.h"
  #include "Xmd.h"
  #include "Xproto.h"
***************
*** 411,432 ****
      Mask 	changes;
      GCPtr	pGCDst;
  {
!     RegionPtr		pClip;
! 
!     if(changes & GCClipMask)
!     {
! 	if(pGCDst->clientClipType == CT_PIXMAP)
! 	{
! 	    ((PixmapPtr)pGCDst->clientClip)->refcnt++;
! 	}
! 	else if(pGCDst->clientClipType == CT_REGION)
! 	{
! 	    pClip = (RegionPtr) pGCDst->clientClip;
! 	    pGCDst->clientClip =
! 	        (pointer)(* pGCDst->pScreen->RegionCreate)(NULL, 1);
! 	    (* pGCDst->pScreen->RegionCopy)(pGCDst->clientClip, pClip);
! 	}
!     }
  }
  
  static void
--- 411,417 ----
      Mask 	changes;
      GCPtr	pGCDst;
  {
!     return;
  }
  
  static void
--[0684]--