After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 774414 - Thread leak
Thread leak
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: general
3.20.x
Other Linux
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-11-14 15:04 UTC by Christophe Fergeau
Modified: 2016-11-21 15:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Tentative Fix (407 bytes, patch)
2016-11-15 13:10 UTC, Sebastien Nobert
committed Details | Review

Description Christophe Fergeau 2016-11-14 15:04:36 UTC
See https://bugzilla.redhat.com/show_bug.cgi?id=1337007#c30 for detailed explanation:


 sebastien.nobert@guavus.com 2016-11-11 17:13:00 EST

There is a process-lifetime memory leak cause by the launch of new thread to gather net stat and io stat. The thread are joined only when the application is closed.

Thread should probalby be created detached.

Here is some output from 
#valgrind --tool=massif --depth=50 --pages-as-heap=yes gnome-boxes

...
--------------------------------------------------------------------------------
  n        time(i)         total(B)   useful-heap(B) extra-heap(B)    stacks(B)
--------------------------------------------------------------------------------
 49 27,131,871,418   52,192,754,560   52,192,754,560             0            0
100.00% (52,192,754,560B) (page allocation syscalls) mmap/mremap/brk, --alloc-fns, etc.
->98.57% (51,448,250,368B) 0xA46B419: mmap (mmap.c:34)
| ->96.43% (50,331,045,888B) 0xA15A0A6: pthread_create@@GLIBC_2.2.5 (allocatestack.c:504)
| | ->96.43% (50,331,045,888B) 0x9B677EE: g_system_thread_new (gthread-posix.c:1169)
| |   ->96.43% (50,331,045,888B) 0x9B49FFD: g_thread_new_internal (gthread.c:870)
| |     ->96.30% (50,263,904,256B) 0x9B4A0B6: g_thread_new (gthread.c:823)
| |     | ->96.27% (50,247,118,848B) 0x1C6973: boxes_async_launcher_launch_co (async-launcher.vala:24)
| |     | | ->48.13% (25,119,363,072B) 0x161009: boxes_libvirt_machine_update_net_stat_co (libvirt-machine.c:2661)
| |     | | | ->48.13% (25,119,363,072B) 0x162BAA: boxes_libvirt_machine_update_stats_co (libvirt-machine.c:2894)
| |     | | |   ->48.13% (25,119,363,072B) 0x9577B65: g_simple_async_result_complete (gsimpleasyncresult.c:801)
| |     | | |     ->48.13% (25,119,363,072B) 0x162220: boxes_libvirt_machine_update_io_stat_co (libvirt-machine.c:2472)
| |     | | |       ->48.13% (25,119,363,072B) 0x9577B65: g_simple_async_result_complete (gsimpleasyncresult.c:801)
| |     | | |         ->48.13% (25,119,363,072B) 0x1C6896: boxes_async_launcher_launch_co (async-launcher.vala:21)
| |     | | |           ->48.13% (25,119,363,072B) 0x9B236B8: g_main_context_dispatch (gmain.c:3154)
| |     | | |             ->48.13% (25,119,363,072B) 0x9B23A6E: g_main_context_iterate.isra.29 (gmain.c:3840)
| |     | | |               ->48.13% (25,119,363,072B) 0x9B23B1A: g_main_context_iteration (gmain.c:3901)
| |     | | |                 ->48.13% (25,119,363,072B) 0x95AF48B: g_application_run (gapplication.c:2381)
| |     | | |                   ->48.13% (25,119,363,072B) 0x177297: _vala_main (main.c:551)
| |     | | |                     ->48.13% (25,119,363,072B) 0xA38E72F: (below main) (libc-start.c:289)
| |     | | |                       
| |     | | ->48.11% (25,110,970,368B) 0x1626E5: boxes_libvirt_machine_update_io_stat_co (libvirt-machine.c:2389)
| |     | | | ->48.11% (25,110,970,368B) 0x162E63: boxes_libvirt_machine_update_stats_co (libvirt-machine.c:2887)
| |     | | |   ->48.11% (25,110,970,368B) 0x95891F1: g_task_return_now (gtask.c:1107)
| |     | | |     ->48.11% (25,110,970,368B) 0x9589227: complete_in_idle_cb (gtask.c:1121)
| |     | | |       ->48.11% (25,110,970,368B) 0x9B236B8: g_main_context_dispatch (gmain.c:3154)
| |     | | |         ->48.11% (25,110,970,368B) 0x9B23A6E: g_main_context_iterate.isra.29 (gmain.c:3840)
| |     | | |           ->48.11% (25,110,970,368B) 0x9B23B1A: g_main_context_iteration (gmain.c:3901)
| |     | | |             ->48.11% (25,110,970,368B) 0x95AF48B: g_application_run (gapplication.c:2381)
| |     | | |               ->48.11% (25,110,970,368B) 0x177297: _vala_main (main.c:551)
| |     | | |                 ->48.11% (25,110,970,368B) 0xA38E72F: (below main) (libc-start.c:289)
| |     | | |                   
| |     | | ->00.03% (16,785,408B) in 1+ places, all below ms_print's threshold (01.00%)
| |     | | 
| |     | ->00.03% (16,785,408B) in 1+ places, all below ms_print's threshold (01.00%)
| |     | 
| |     ->00.13% (67,141,632B) in 1+ places, all below ms_print's threshold (01.00%)
| |
Comment 1 Sebastien Nobert 2016-11-15 13:10:44 UTC
Created attachment 339927 [details] [review]
Tentative Fix

This patch fix the issue for me. I'm not a Gnome dev but looking at the doc I saw a GThreadPool would probably be more appropriate.
Comment 2 Zeeshan Ali 2016-11-21 15:01:40 UTC
(In reply to Sebastien Nobert from comment #1)
> Created attachment 339927 [details] [review] [review]
> Tentative Fix
> 
> This patch fix the issue for me. I'm not a Gnome dev but looking at the doc
> I saw a GThreadPool would probably be more appropriate.

I think ThreadPool is for running the same task/function with different data. That's not the case here.
Comment 3 Zeeshan Ali 2016-11-21 15:11:13 UTC
Review of attachment 339927 [details] [review]:

Thanks. I've merged this and created a commit for you but please in future either use git-format-patch or git-bz to create/upload patches. Also please do read through this & try to follow it: https://wiki.gnome.org/Git/CommitMessages