! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Memory leaks in tabwin.c
Status:
RESOLVED: FIXED

Comments

Description Alistair Buxton 2018-02-24 13:47:01 CET
This source file calls gtk_container_get_children in various places which according to the Gtk docs "returns a newly allocated list" and is annotated "[transfer container]". This means the caller is responsible for freeing the list (but not the elements inside the list). However, tabwin.c does not do this and so (for example) holding down alt-tab for a long times causes it to leak relatively large amounts of memory.

Valgrind log:

==20972== 
==20972== 17,674,944 bytes in 736,456 blocks are indirectly lost in loss record 4,113 of 4,114
==20972==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20972==    by 0x76BD718: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==20972==    by 0x76D4922: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==20972==    by 0x76B3C95: g_list_prepend (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==20972==    by 0x602A76E: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.30)
==20972==    by 0x5FFA409: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.30)
==20972==    by 0x602E0EA: gtk_container_get_children (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.30)
==20972==    by 0x43DAEA: tabwinChange2Selected (tabwin.c:901)
==20972==    by 0x41A9D4: clientCycleEventFilter (cycle.c:329)
==20972==    by 0x41C551: eventXfwmFilter (event_filter.c:158)
==20972==    by 0x6619F30: ??? (in /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0.2400.30)
==20972==    by 0x661B1E3: ??? (in /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0.2400.30)
==20972== 
==20972== 35,346,312 (17,672,592 direct, 17,673,720 indirect) bytes in 736,358 blocks are definitely lost in loss record 4,114 of 4,114
==20972==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20972==    by 0x76BD718: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==20972==    by 0x76D4922: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==20972==    by 0x76B3C95: g_list_prepend (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==20972==    by 0x602A76E: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.30)
==20972==    by 0x5FFA409: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.30)
==20972==    by 0x602E0EA: gtk_container_get_children (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.30)
==20972==    by 0x43DAEA: tabwinChange2Selected (tabwin.c:901)
==20972==    by 0x41A9D4: clientCycleEventFilter (cycle.c:329)
==20972==    by 0x41C551: eventXfwmFilter (event_filter.c:158)
==20972==    by 0x6619F30: ??? (in /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0.2400.30)
==20972==    by 0x661B1E3: ??? (in /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0.2400.30)
==20972== 
==20972== LEAK SUMMARY:
==20972==    definitely lost: 35,508,080 bytes in 1,479,323 blocks
==20972==    indirectly lost: 17,784,238 bytes in 740,904 blocks
==20972==      possibly lost: 2,300 bytes in 37 blocks
==20972==    still reachable: 1,699,861 bytes in 15,446 blocks
==20972==                       of which reachable via heuristic:
==20972==                         length64           : 2,232 bytes in 33 blocks
==20972==                         newarray           : 1,744 bytes in 29 blocks
==20972==         suppressed: 0 bytes in 0 blocks
==20972== 
==20972== For counts of detected and suppressed errors, rerun with: -v
==20972== Use --track-origins=yes to see where uninitialised values come from
==20972== ERROR SUMMARY: 77 errors from 49 contexts (suppressed: 0 from 0)
Comment 1 Andre Miranda editbugs 2018-02-24 16:49:29 CET
Created attachment 7617 
fix leaks

The attached patch fixes the leaks pointed out by Alistair, but they were not enough, there was also another leak in tabwin, css = gtk_css_provider_to_string (provider);
Comment 2 Olivier Fourdan editbugs 2018-03-05 11:26:18 CET
Can you please attach a "git format-patch" instead?
Comment 3 Andre Miranda editbugs 2018-03-06 22:49:05 CET
Created attachment 7632 
git format patch

Here you are.
Comment 4 Git Bot editbugs 2018-03-31 15:26:43 CEST
Andre Miranda referenced this bugreport in commit 2fb59f21014b44dd36cce8740ad919f4cba608d3

Fix memory leaks in tabwin

https://git.xfce.org/xfce/xfwm4/commit?id=2fb59f21014b44dd36cce8740ad919f4cba608d3
Comment 5 Andre Miranda editbugs 2018-08-08 04:48:16 CEST
@ofourdan, shouldn't we close this bug?

Bug #14240

Reported by:
Alistair Buxton
Reported on: 2018-02-24
Last modified on: 2018-10-27

People

Assignee:
Olivier Fourdan
CC List:
1 user

Version

Version:
unspecified

Attachments

fix leaks (5.31 KB, patch)
2018-02-24 16:49 CET , Andre Miranda
no flags
git format patch (5.64 KB, patch)
2018-03-06 22:49 CET , Andre Miranda
no flags

Additional information