Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.420 diff -u -2 -0 -r1.420 ChangeLog --- xc/ChangeLog 3 Oct 2004 15:01:31 -0000 1.420 +++ xc/ChangeLog 3 Oct 2004 15:26:08 -0000 @@ -1,20 +1,28 @@ +2004-10-03 Roland Mainz + * xc/programs/Xserver/Xprint/ps/PsGC.c + * xc/programs/Xserver/Xprint/ps/PsPixmap.c + Bugzilla #1416: Fix Xprt PostScript DDX crashes when copying + offscreen pixmap content to the same pixmap (the crash can + be reproduced with % x11perf -copypixpix500 ... # or the + reduced testcase in bug #1416 (attachment #993)). + 2004-10-03 Vladimir Dergachev Modified: * xc/programs/Xserver/hw/xfree86/drivers/i2c/fi1236.c Make sure formatting style is consistent within a single function. MT2032 functions are best be in separate file anyway. 2004-10-03 Vladimir Dergachev Modified: * xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c Fix compilation with gcc 3.4.x (patch by Ronny V. Vindenes) 2004-10-03 Vladimir Dergachev Modified: * xc/programs/Xserver/hw/xfree86/drivers/i2c/fi1236.c Fix compilation with gcc 3.4.x Cleanup xf86DrvMsg noise. Index: xc/programs/Xserver/Xprint/ps/PsGC.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsGC.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 PsGC.c --- xc/programs/Xserver/Xprint/ps/PsGC.c 18 Jul 2004 05:21:20 -0000 1.3 +++ xc/programs/Xserver/Xprint/ps/PsGC.c 3 Oct 2004 15:26:24 -0000 @@ -363,40 +363,50 @@ PsClipPtr dst = (PsClipPtr)pDst->clientClip; PsDestroyClip(pDst); pDst->clientClipType = pSrc->clientClipType; *dst = *src; if( src->rects ) { dst->rects = (PsRectPtr)xalloc(src->nRects*sizeof(PsRectRec)); memcpy(dst->rects, src->rects, src->nRects*sizeof(PsRectRec)); } if( src->elms ) dst->elms = PsCloneFillElementList(src->nElms, src->elms); } GCPtr PsCreateAndCopyGC(DrawablePtr pDrawable, GCPtr pSrc) { GCPtr pDst; + if (pSrc == NULL) { + /* https://freedesktop.org/bugzilla/show_bug.cgi?id=1416 ("'x11perf + * -copypixpix500' crashes Xprt's PostScript DDX [PsCreateAndCopyGC"): + * I have no clue whether this is the real fix or just wallpapering + * over the crash (that's why we warn here loudly when this + * happens) ... */ + fprintf(stderr, "PsCreateAndCopyGC: pSrc == NULL\n"); + return NULL; + } + if ((pDst = CreateScratchGC(pDrawable->pScreen, pDrawable->depth)) == NULL) { return NULL; } if (CopyGC(pSrc, pDst, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule | GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont | GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCDashOffset | GCDashList | GCArcMode) != Success) { (void)FreeGC(pDst, (GContext)0); return NULL; } Index: xc/programs/Xserver/Xprint/ps/PsPixmap.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsPixmap.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 PsPixmap.c --- xc/programs/Xserver/Xprint/ps/PsPixmap.c 18 Aug 2004 18:41:40 -0000 1.3 +++ xc/programs/Xserver/Xprint/ps/PsPixmap.c 3 Oct 2004 15:26:24 -0000 @@ -75,60 +75,59 @@ ********************************************************************/ #include "windowstr.h" #include "gcstruct.h" #include "Ps.h" #define _BitsPerPixel(d) (\ (1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \ (PixmapWidthPaddingInfo[d].padRoundUp+1)) PixmapPtr PsCreatePixmap( ScreenPtr pScreen, int width, int height, int depth) { PixmapPtr pPixmap; - pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec)); + pPixmap = (PixmapPtr)xcalloc(1, sizeof(PixmapRec)); if( !pPixmap) return NullPixmap; pPixmap->drawable.type = DRAWABLE_PIXMAP; pPixmap->drawable.class = 0; pPixmap->drawable.pScreen = pScreen; pPixmap->drawable.depth = depth; pPixmap->drawable.bitsPerPixel = _BitsPerPixel(depth); pPixmap->drawable.id = 0; pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pPixmap->drawable.x = 0; pPixmap->drawable.y = 0; pPixmap->drawable.width = width; pPixmap->drawable.height = height; pPixmap->devKind = 0; pPixmap->refcnt = 1; - pPixmap->devPrivate.ptr = (PsPixmapPrivPtr)xalloc(sizeof(PsPixmapPrivRec)); + pPixmap->devPrivate.ptr = (PsPixmapPrivPtr)xcalloc(1, sizeof(PsPixmapPrivRec)); if( !pPixmap->devPrivate.ptr ) { xfree(pPixmap); return NullPixmap; } - memset(pPixmap->devPrivate.ptr, 0, sizeof(PsPixmapPrivRec)); return pPixmap; } Bool PsDestroyPixmap(PixmapPtr pPixmap) { PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pPixmap->devPrivate.ptr; DisplayListPtr disp = priv->dispList; if( --pPixmap->refcnt ) return TRUE; while( disp ) { int i; DisplayListPtr oldDisp = disp; disp = disp->next; for( i=0 ; inelms ; i++ ) { DisplayElmPtr elm = &oldDisp->elms[i]; switch(elm->type) @@ -175,45 +174,45 @@ if (elm->type != BeginFrameCmd && elm->type != EndFrameCmd) { (void) FreeGC(elm->gc, (GContext) 0); } } xfree(oldDisp); } xfree(priv); xfree(pPixmap); return TRUE; } DisplayListPtr PsGetFreeDisplayBlock(PsPixmapPrivPtr priv) { DisplayListPtr disp = priv->dispList; for(; disp ; disp=disp->next ) { if( disp->nelms>=DPY_BLOCKSIZE && disp->next ) continue; if( disp->nelmsnext = (DisplayListPtr)xalloc(sizeof(DisplayListRec)); + disp->next = (DisplayListPtr)xcalloc(1, sizeof(DisplayListRec)); disp->next->next = (DisplayListPtr)0; disp->next->nelms = 0; } - disp = (DisplayListPtr)xalloc(sizeof(DisplayListRec)); + disp = (DisplayListPtr)xcalloc(1, sizeof(DisplayListRec)); disp->next = (DisplayListPtr)0; disp->nelms = 0; priv->dispList = disp; return(disp); } void PsReplay(DisplayElmPtr elm, DrawablePtr pDrawable) { switch(elm->type) { case PolyPointCmd: PsPolyPoint(pDrawable, elm->gc, elm->c.polyPts.mode, elm->c.polyPts.nPoints, elm->c.polyPts.pPoints); break; case PolyLineCmd: PsPolyLine(pDrawable, elm->gc, elm->c.polyPts.mode, elm->c.polyPts.nPoints, elm->c.polyPts.pPoints); break; case PolySegmentCmd: @@ -463,59 +462,60 @@ elm->type = EndFrameCmd; dDisp->nelms += 1; } PsElmPtr PsCreateFillElementList(PixmapPtr pix, int *nElms) { PsElmPtr elms = (PsElmPtr)0; PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; DisplayListPtr disp = priv->dispList; PsArcEnum styl; *nElms = 0; for(; disp ; disp=disp->next ) { int i; DisplayElmPtr elm = disp->elms; for( i=0 ; inelms ; i++,elm++ ) { + if( !elm->gc ) continue; /* workaround for https://freedesktop.org/bugzilla/show_bug.cgi?id=1416 */ if( !elm->gc->fgPixel ) continue; switch(elm->type) { case FillPolygonCmd: *nElms += 1; break; case PolyFillRectCmd: *nElms += elm->c.rects.nRects; break; case PolyFillArcCmd: *nElms += elm->c.arcs.nArcs; break; } } } if( (*nElms) ) { - elms = (PsElmPtr)xalloc((*nElms)*sizeof(PsElmRec)); + elms = (PsElmPtr)xcalloc(1, (*nElms)*sizeof(PsElmRec)); if( elms ) { disp = priv->dispList; *nElms = 0; for(; disp ; disp=disp->next ) { int i, k; DisplayElmPtr elm = disp->elms; for( i=0 ; inelms ; i++,elm++ ) { if( !elm->gc->fgPixel ) continue; switch(elm->type) { case FillPolygonCmd: elms[*nElms].type = PSOUT_POINTS; elms[*nElms].nPoints = elm->c.polyPts.nPoints; elms[*nElms].c.points = (PsPointPtr)xalloc(elms[*nElms].nPoints*sizeof(PsPointRec)); for( k=0 ; kc.arcs.pArcs[k].angle1; elms[*nElms].c.arc.a2 = elm->c.arcs.pArcs[k].angle2; elms[*nElms].c.arc.style = styl; *nElms += 1; } break; } } } } } return(elms); } PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms) { int i; PsElmPtr newElms; - newElms = (PsElmPtr)xalloc(nElms*sizeof(PsElmRec)); + newElms = (PsElmPtr)xcalloc(1, nElms*sizeof(PsElmRec)); if( !newElms ) return(newElms); for( i=0 ; i