This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin/X just now started to crash with Solaris app, 8bpp UPDATE


On Wed, 27 Oct 2004, Sebastian wrote:

> Here's another update...
> I've located what goes wrong when Cygwin/X crashes.
> In shadow.c, shadowSetup() sets all functionpointers, pScreen->CreateGC, pScreen->PaintWindowBackground etc..
> then in the functions shadowCreateGC, shadowPaintWindow etc.. the screen privates are retreived ,shadowScrPriv(), then the function pointers are set again using the unwrap macro
> #define unwrap(priv, real, mem) {\
>     real->mem = priv->mem; \
> }
> In shadowPaintWindow for example.
> shadowScrPriv(pScreen);  //retreive screen privates
> if(what == PW_BACKGROUND) {
>    unwrap (pScrPriv, pScreen, PaintWindowBackground);  //set the function pointer
>    (*pScreen->PaintWindowBackground) (pWindow, prgn, what); //paint
>    wrap (pScrPriv, pScreen, PaintWindowBackground, shadowPaintWindow);
> 
> 98% of the time the functionpointers are set correctly, although sometimes they are completely bananas and are set to 0x99 or 0xff which causes XWin to crash immediately. I've "corrected" the effect of this bug by adding if(((int)pScreen->GetImage & 0xffffff00) == NULL)
>     	pScreen->GetImage = 0x4b8bf9;
> and respectively for pScreen->PaintWindowBackground etc...
> So now whenever a functionpointer gets corrupted XWin doesn't crash and I can debug and continue monitoring the functionpointers. It must be because shadowScrPriv(), shadow.h
> 
> #define shadowGetScrPriv(pScr)  ((shadowScrPrivPtr) (pScr)->devPrivates[shadowScrPrivateIndex].ptr)
> #define shadowScrPriv(pScr)	shadowScrPrivPtr    pScrPriv = shadowGetScrPriv(pScr)
> 
> retreives incorrect screen privates. But why? I'm not familiar enough with the code to figure it out.
> Hopefully some of you will have some ideas on this ;)

pScreen->devPrivates is an array for the xserver layers to store own data (screen privates).
Every layer which wants to add data must allocate an index (shadowScrPrivateIndex) and can
now store a pointer to some data pScreen->devPrivates[shadowScrPrivateIndex]. 

shadowGetScrPriv just retrieves the pointer and casts the void* to a meaningful type.
shadowScrPrivPtr is just a shortcut to define a variable (pScrPriv) which holds the 
pointer to the screen privates.

You will get no valid data if
a) shadowScrPrivateIndex is wrong (-1 or something like that)
b) pScreen->devPrivates[shadowScrPrivateIndex] was overwritten (maybe a bug in another layer)
c) the screen privates are garbled. Some part of the code may have written random data.
d) the screen privates are garbled. Some part of the code was not properly recompiled and 
   the size, alignment of elements in a struct does not match
e) Threading issue. Does the error occur without -multiwindow and -clipboard?

bye
	ago 
-- 
 Alexander.Gottwald@s1999.tu-chemnitz.de 
 http://www.gotti.org           ICQ: 126018723


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]