All of lore.kernel.org
 help / color / mirror / Atom feed
* ell/main.c Memory leak
@ 2016-06-03 21:09 Denis Kenzior
  2016-06-03 22:05 ` Andrzej Zaborowski
  2016-06-03 22:08 ` Mat Martineau
  0 siblings, 2 replies; 7+ messages in thread
From: Denis Kenzior @ 2016-06-03 21:09 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 4930 bytes --]

This is from iwd:

[DBUS] > 6c 04 01 01 98 00 00 00 04 00 00 00 68 00 00 00  l...........h...
[DBUS]   01 01 6f 00 01 00 00 00 2f 00 00 00 00 00 00 00  ..o...../.......
[DBUS]   03 01 73 00 0f 00 00 00 49 6e 74 65 72 66 61 63  ..s.....Interfac
[DBUS]   65 73 41 64 64 65 64 00 02 01 73 00 22 00 00 00  esAdded...s."...
[DBUS]   6f 72 67 2e 66 72 65 65 64 65 73 6b 74 6f 70 2e  org.freedesktop.
[DBUS]   44 42 75 73 2e 4f 62 6a 65 63 74 4d 61 6e 61 67  DBus.ObjectManag
[DBUS]   65 72 00 00 00 00 00 00 08 01 67 00 0a 6f 61 7b  er........g..oa{
[DBUS]   73 61 7b 73 76 7d 7d 00                          sa{sv}}.
[DBUS]   02 00 00 00 2f 33 00 00 88 00 00 00 00 00 00 00  ..../3..........
[DBUS]   16 00 00 00 6e 65 74 2e 63 6f 6e 6e 6d 61 6e 2e  ....net.connman.
[DBUS]   69 77 64 2e 44 65 76 69 63 65 00 00 33 00 00 00  iwd.Device..3...
[DBUS]   04 00 00 00 4e 61 6d 65 00 01 73 00 06 00 00 00  ....Name..s.....
[DBUS]   77 6c 70 32 73 30 00 00 07 00 00 00 41 64 64 72  wlp2s0......Addr
[DBUS]   65 73 73 00 01 73 00 00 06 00 00 00 a0 a8 cd 1c  ess..s..........
[DBUS]   7e c9 00 00 00 00 00 00 27 00 00 00 6e 65 74 2e  ~.......'...net.
[DBUS]   63 6f 6e 6e 6d 61 6e 2e 69 77 64 2e 57 69 46 69  connman.iwd.WiFi
[DBUS]   53 69 6d 70 6c 65 43 6f 6e 66 69 67 75 72 61 74  SimpleConfigurat
[DBUS]   69 6f 6e 00 00 00 00 00                          ion.....
src/scan.c:scan_notify() Scan notification 33
[DBUS] disconnect
D-Bus disconnected, quitting...
src/eap.c:__eap_method_disable()
src/eap.c:eap_md5_exit()
src/eap-tls.c:eap_tls_exit()
src/eap-ttls.c:eap_ttls_exit()
src/main.c:nl80211_vanished() Lost nl80211 interface
src/wsc.c:wsc_exit()
src/scan.c:scan_exit()
src/scan.c:scan_context_free() sc: 0x53f4690
src/netdev.c:netdev_free() Freeing netdev wlp2s0[3]
src/netdev.c:netdev_exit() Closing route netlink socket
src/wiphy.c:wiphy_free() Freeing wiphy phy0
src/dbus.c:dbus_exit()
==11733==
==11733== HEAP SUMMARY:
==11733==     in use at exit: 1,048 bytes in 2 blocks
==11733==   total heap usage: 759 allocs, 757 frees, 88,760 bytes allocated
==11733==
==11733== 24 bytes in 1 blocks are still reachable in loss record 1 of 2
==11733==    at 0x4C2C970: malloc (vg_replace_malloc.c:296)
==11733==    by 0x41CA37: l_malloc (util.c:62)
==11733==    by 0x41DE00: l_queue_new (queue.c:63)
==11733==    by 0x422B9D: create_epoll (main.c:102)
==11733==    by 0x422B9D: idle_add (main.c:263)
==11733==    by 0x42361A: l_idle_create (idle.c:108)
==11733==    by 0x4397AF: schedule_emit_signals (dbus-service.c:1081)
==11733==    by 0x43A6EE: _dbus_object_tree_remove_interface 
(dbus-service.c:1503)
==11733==    by 0x439F45: check_interface_used (dbus-service.c:1306)
==11733==    by 0x41F342: l_hashmap_foreach (hashmap.c:532)
==11733==    by 0x439FBC: _dbus_object_tree_unregister_interface 
(dbus-service.c:1320)
==11733==    by 0x42CC6B: l_dbus_unregister_interface (dbus.c:1715)
==11733==    by 0x418BE9: wsc_exit (wsc.c:341)
==11733==
==11733== 1,024 bytes in 1 blocks are still reachable in loss record 2 of 2
==11733==    at 0x4C2C970: malloc (vg_replace_malloc.c:296)
==11733==    by 0x422B85: create_epoll (main.c:98)
==11733==    by 0x422B85: idle_add (main.c:263)
==11733==    by 0x42361A: l_idle_create (idle.c:108)
==11733==    by 0x4397AF: schedule_emit_signals (dbus-service.c:1081)
==11733==    by 0x43A6EE: _dbus_object_tree_remove_interface 
(dbus-service.c:1503)
==11733==    by 0x439F45: check_interface_used (dbus-service.c:1306)
==11733==    by 0x41F342: l_hashmap_foreach (hashmap.c:532)
==11733==    by 0x439FBC: _dbus_object_tree_unregister_interface 
(dbus-service.c:1320)
==11733==    by 0x42CC6B: l_dbus_unregister_interface (dbus.c:1715)
==11733==    by 0x418BE9: wsc_exit (wsc.c:341)
==11733==    by 0x4029D3: nl80211_vanished (main.c:117)
==11733==    by 0x428D49: l_genl_family_unref (genl.c:1057)
==11733==
==11733== LEAK SUMMARY:
==11733==    definitely lost: 0 bytes in 0 blocks
==11733==    indirectly lost: 0 bytes in 0 blocks
==11733==      possibly lost: 0 bytes in 0 blocks
==11733==    still reachable: 1,048 bytes in 2 blocks
==11733==         suppressed: 0 bytes in 0 blocks


This leak happens in create_epoll(). The sequence of events is a bit 
bizarre:

1. We send an invalid signal
2. DBus detects that and kills our connection
3. l_main_quit is called, which frees all main event loop resources
4. We start tearing down the rest of the daemon
	a) At some point we unregister some interfaces
	b) ObjectManager schedules the transmission of a signal
	c) idle_create gets called, which calls create_epoll()
5. DBus is destroyed, which removes the idle source in 4c

Unfortunately at this point, nothing actually frees the resources 
created by create_epoll().

I'm thinking l_main_run needs to be split up into l_main_new, l_main_run 
and l_main_destroy.

Thoughts?

Regards,
-Denis

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-06-03 23:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-03 21:09 ell/main.c Memory leak Denis Kenzior
2016-06-03 22:05 ` Andrzej Zaborowski
2016-06-03 22:16   ` Denis Kenzior
2016-06-03 22:08 ` Mat Martineau
2016-06-03 22:25   ` Denis Kenzior
2016-06-03 23:17     ` Mat Martineau
2016-06-03 23:56       ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.