Bug 25028

Summary: List of memory leaks of Xorg
Product: xorg Reporter: Zdenek Kabelac <zdenek.kabelac>
Component: Input/evdevAssignee: Peter Hutterer <peter.hutterer>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Zdenek Kabelac 2009-11-11 02:05:19 UTC
I'll list couple major leaks easily found by valgrind.

Leaks could be seen by this simple run:
(using nonsuid Xorg)

valgrind --show-reachable=yes --leak-check=yes Xorg :1 -terminate
run some apps on display :1 and exit and see collected leaks:

For leaks detection was used Fedora12 Rawhide
xorg-x11-server-Xorg-1.7.1-7.fc12.x86_64
valgrind-3.5.0-9.x86_64

I think many of them are probably not really important as they come for the 1st. time initialization and are quite small - but couple major ones are worth fixing especially when they are quite easy to fix.
Many leaks are probably releated to just couple missing deallocation calls (as usually there is some routine already written to free these resources but they are not properly called. 

Leaks are not critical as they occurs only on internal Xorg restart thus they do not have impact on 1 run of of Xorg.
---

917,504 bytes in 512 blocks are still reachable in loss record 915 of 916
   at 0x4C2415D: malloc (vg_replace_malloc.c:195)
   by 0x462705: Xcalloc (utils.c:1098)
   by 0x442F1C: InitEventList (getevents.c:965)
   by 0x49E3B8: mieqInit (mieq.c:114)
   by 0x46E068: InitInput (xf86Init.c:1124)
   by 0x421CB6: main (main.c:257)

Could be probably fixed by usage of  mieqFini()->FreeEventList()
(although functions like InitOutput in hw/xfree86/common/xf86Init.c have its reserves in deallocation on error path)

---
111,616 bytes in 1 blocks are still reachable in loss record 913 of 916
   at 0x4C2415D: malloc (vg_replace_malloc.c:195)
   by 0x462705: Xcalloc (utils.c:1098)
   by 0x4433B5: AllocateMotionHistory (getevents.c:345)
   by 0x424FF8: InitValuatorClassDeviceStruct (devices.c:1182)
   by 0x42516E: InitPointerDeviceStruct (devices.c:1462)
   by 0x425AAE: CorePointerProc (devices.c:566)
   by 0x426455: ActivateDevice (devices.c:470)
   by 0x427390: InitCoreDevices (devices.c:610)
   by 0x421CA9: main (main.c:256)


There is some funny comment for FreeDeviceClass() inside dix/devices.c
I assume someone should properly check that RemoveDevice() is doing it's jobs properly.

---
17,664 bytes in 23 blocks are definitely lost in loss record 908 of 916
   at 0x4C2415D: malloc (vg_replace_malloc.c:195)
   by 0x462705: Xcalloc (utils.c:1098)
   by 0x445D44: dixAllocatePrivate (privates.c:118)
   by 0x445DB2: dixSetPrivate (privates.c:193)
   by 0x545E78: miDCRealizeCursor (midispcur.c:181)
   by 0x560223: AnimCurRealizeCursor (animcur.c:283)
   by 0x422D60: AllocARGBCursor (cursor.c:243)
   by 0x4CBFDC: ProcRenderCreateCursor (render.c:1690)
   by 0x42C69B: Dispatch (dispatch.c:445)
   by 0x421CF9: main (main.c:285)

Looks like some missing dixFreePrivates() from FreeCursor() ?


Just let me know - once they are fixed and new packages are build with them - so I'll eventually report more of them.

(Ideally you could tackle couple more of them yourself).
Comment 1 Peter Hutterer 2009-11-29 21:23:38 UTC
sorry about the delay.

(In reply to comment #0)
> 917,504 bytes in 512 blocks are still reachable in loss record 915 of 916
>    at 0x4C2415D: malloc (vg_replace_malloc.c:195)
>    by 0x462705: Xcalloc (utils.c:1098)
>    by 0x442F1C: InitEventList (getevents.c:965)
>    by 0x49E3B8: mieqInit (mieq.c:114)
>    by 0x46E068: Initput (xf86Init.c:1124)
>    by 0x421CB6: main (main.c:257)
> 
> Could be probably fixed by usage of  mieqFini()->FreeEventList()
> (although functions like InitOutput in hw/xfree86/common/xf86Init.c have its
> reserves in deallocation on error path)
> 
> ---
> 111,616 bytes in 1 blocks are still reachable in loss record 913 of 916
>    at 0x4C2415D: malloc (vg_replace_malloc.c:195)
>    by 0x462705: Xcalloc (utils.c:1098)
>    by 0x4433B5: AllocateMotionHistory (getevents.c:345)
>    by 0x424FF8: InitValuatorClassDeviceStruct (devices.c:1182)
>    by 0x42516E: InitPointerDeviceStruct (devices.c:1462)
>    by 0x425AAE: CorePointerProc (devices.c:566)
>    by 0x426455: ActivateDevice (devices.c:470)
>    by 0x427390: InitCoreDevices (devices.c:610)
>    by 0x421CA9: main (main.c:256)
> 
> 
> There is some funny comment for FreeDeviceClass() inside dix/devices.c
> I assume someone should properly check that RemoveDevice() is doing it's jobs
> properly.

included in pull request here:
http://lists.freedesktop.org/archives/xorg-devel/2009-November/003749.html

> 17,664 bytes in 23 blocks are definitely lost in loss record 908 of 916
>    at 0x4C2415D: malloc (vg_replace_malloc.c:195)
>    by 0x462705: Xcalloc (utils.c:1098)
>    by 0x445D44: dixAllocatePrivate (privates.c:118)
>    by 0x445DB2: dixSetPrivate (privates.c:193)
>    by 0x545E78: miDCRealizeCursor (midispcur.c:181)
>    by 0x560223: AnimCurRealizeCursor (animcur.c:283)
>    by 0x422D60: AllocARGBCursor (cursor.c:243)
>    by 0x4CBFDC: ProcRenderCreateCursor (render.c:1690)
>    by 0x42C69B: Dispatch (dispatch.c:445)
>    by 0x421CF9: main (main.c:285)
> 
> Looks like some missing dixFreePrivates() from FreeCursor() ?

this should be fixed since 0573042cddb6f9942e408687a16c6842e62a8bfa.
Comment 2 Peter Hutterer 2010-12-09 13:36:29 UTC
fixed, afaict with the commits listed above

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.