unwrap Glyphs, Composite and AddTraps at damageCloseScreen
Submitted by SooChan Lim
Assigned to Xorg Project Team
Description
I had found that Xserver did not execute the exaGlyphsFini() while the Xserver calls closeScreen functions. The issue is that the server cannot free the exaglyph cache picture due to not calling exaGlyphsFini(),and then it cause the memory leak when the Xserver is termitated.
I have analyzed the closeScreen routines and I found the reason why the exaGlyphsFini() is not called. It is because the ps->Glyphs is not equal to exaGlyphs at exaCloseScreen.
static Bool exaCloseScreen(int i, ScreenPtr pScreen) { ExaScreenPriv(pScreen); #ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif
if (ps->Glyphs == exaGlyphs) /* This is not TRUE */
exaGlyphsFini(pScreen);
---- omitted ---
xfree (pExaScr);
return (*pScreen->CloseScreen) (i, pScreen);
}
In a depth analysis, I realized that the root cause of this leak is that unwrapping the private functions, which are Glyphs, Composite, and AddTraps, does not exist at damageCloseScreen().
The private functions of Glyphs, Composite, AddTraps are created at the time of DamageSetup(). However, there is no calling of unwrapping at the time of damageCloseScreen(). Therefore, I suggest that damageCloseScreen() func contains unwrap function for the Glyphs, Compsoite, and AddTraps for preventing the memory leak.
The code to be fixed is below. Please check the code.
=============================================================================== static Bool damageCloseScreen (int i, ScreenPtr pScreen) { damageScrPriv(pScreen);
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
unwrap (pScrPriv, pScreen, DestroyPixmap);
unwrap (pScrPriv, pScreen, CreateGC);
unwrap (pScrPriv, pScreen, CopyWindow);
unwrap (pScrPriv, pScreen, CloseScreen);
if (ps) {
unwrap (pScrPriv, ps, Glyphs);
unwrap (pScrPriv, ps, Composite);
unwrap (pScrPriv, ps, AddTraps);
}
xfree (pScrPriv);
return (*pScreen->CloseScreen) (i, pScreen);
}
Thank you. SooChan Lim.
Version: 7.5 (2009.10)