leak due spice-widget-egl -> eglInitialize
Submitted by Victor Toso
Assigned to Spice Bug List
Description
Leak is: ==30366== 72,704 bytes in 1 blocks are definitely lost in loss record 9,971 of 9,978 ==30366== at 0x4C28BF6: malloc (vg_replace_malloc.c:299) ==30366== by 0x3962AEDF: ??? ==30366== by 0x400F749: call_init.part.0 (dl-init.c:72) ==30366== by 0x400F85A: call_init (dl-init.c:30) ==30366== by 0x400F85A: _dl_init (dl-init.c:120) ==30366== by 0x40143B1: dl_open_worker (dl-open.c:564) ==30366== by 0x400F5F3: _dl_catch_error (dl-error.c:187) ==30366== by 0x40136B2: _dl_open (dl-open.c:649) ==30366== by 0xC45EFC8: dlopen_doit (dlopen.c:66) ==30366== by 0x400F5F3: _dl_catch_error (dl-error.c:187) ==30366== by 0xC45F630: _dlerror_run (dlerror.c:163) ==30366== by 0xC45F060: dlopen@@GLIBC_2.2.5 (dlopen.c:87) ==30366== by 0xF0073B5: dri2_open_driver.isra.7 (egl_dri2.c:452)
Tracking this with gdb:
Breakpoint 1, dri2_open_driver (disp=0xadfee0) at drivers/dri2/egl_dri2.c:419
419 dri2_open_driver(_EGLDisplay *disp)
(gdb) bt
#0 dri2_open_driver (disp=0xadfee0) at drivers/dri2/egl_dri2.c:419
#1 0x00007fffed9ff092 in dri2_load_driver_dri3 (disp=disp@entry=0xadfee0) at drivers/dri2/egl_dri2.c:508
#2 0x00007fffeda01e77 in dri2_initialize_x11_dri3 (drv=<optimized out>, disp=0xadfee0) at drivers/dri2/platform_x11.c:1292
#3 dri2_initialize_x11 (drv=<optimized out>, disp=0xadfee0) at drivers/dri2/platform_x11.c:1464
#4 0x00007fffed9fb8ff in _eglMatchAndInitialize (dpy=0xadfee0) at main/egldriver.c:261
#5 0x00007fffed9fb9b9 in _eglMatchDriver (dpy=dpy@entry=0xadfee0, test_only=test_only@entry=0) at main/egldriver.c:292
#6 0x00007fffed9f7d32 in eglInitialize (dpy=0xadfee0, major=0x7fffffffb67c, minor=0x7fffffffb680) at main/eglapi.c:482
#7 0x00007ffff7599cb7 in spice_egl_init (display=display@entry=0xaa0440, err=err@entry=0x7fffffffb6c0) at spice-widget-egl.c:226
#8 0x00007ffff75938d6 in drawing_area_realize (area=0x6ab3b0, user_data=<optimized out>) at spice-widget.c:571
Looking at khronos docs, eglInitialize [0] says that we must eglTerminate [1] to release resources, which we do. eglTerminate docs also says:
(...) they are not released until they are no longer current as a result of eglMakeCurrent.
but we are calling eglMakeCurrent correctly just before eglTerminate... so I guess it could be some race conditions that makes dlclose() nerver be called?
[0] https://www.khronos.org/registry/egl/sdk/docs/man/html/eglInitialize.xhtml [1] https://www.khronos.org/registry/egl/sdk/docs/man/html/eglTerminate.xhtml