Bug 69332

Summary: regression tests leak memory, file descriptors on NetBSD
Product: dbus Reporter: Simon McVittie <smcv>
Component: coreAssignee: Havoc Pennington <hp>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: medium CC: ajacoutot, chengwei.yang.cn
Version: unspecifiedKeywords: love, patch
Hardware: Other   
OS: NetBSD   
Whiteboard: review?
i915 platform: i915 features:
Attachments: [PATCH 1/3] Fix memory leak for kqueue: replace tab with space
[PATCH 2/3] Fix memory leak for kqueue: shutdown kqueue correctly
[PATCH 3/3] Fix memory leak for kqueue: free memory before assign
[PATCH v2] Fix memory leak for kqueue: shutdown kqueue correctly
[PATCH v3] Fix memory leak for kqueue: shutdown kqueue correctly

Description Simon McVittie 2013-09-13 18:43:37 UTC
On NetBSD 6.0.1, with the tests hacked to make these failures not fatal as they normally are:

./../bus/bus-test: Running SHA1 connection test
./../bus/bus-test: checking for memleaks
2 dbus_malloc blocks were not freed
...
Shell echo service echoed the command line
./../bus/bus-test: checking for memleaks
2 dbus_malloc blocks were not freed
./../bus/bus-test: Running service files reloading test
./../bus/bus-test: checking for memleaks
2 dbus_malloc blocks were not freed
./../bus/bus-test: Running unix fd passing test
./../bus/bus-test: checking for memleaks
2 dbus_malloc blocks were not freed


and I've also seen tests fail complaining that fd 5 was not close-on-exec (in the dbus-spawn tests).

The "core" D-Bus developers are incredibly unlikely to fix this.
Comment 1 Chengwei Yang 2013-09-24 13:46:20 UTC
On FreeBSD 9.1

./../bus/bus-test: checking for memleaks
./../bus/bus-test: Running signals test
./../bus/bus-test: checking for memleaks
./../bus/bus-test: Running SHA1 connection test
./../bus/bus-test: checking for memleaks
2 dbus_malloc blocks were not freed
  D-Bus not compiled with backtrace support so unable to print a backtrace
  Process 75491 sleeping for gdb attach
Comment 2 Chengwei Yang 2013-12-02 04:54:27 UTC
(In reply to comment #0)
> 
> and I've also seen tests fail complaining that fd 5 was not close-on-exec
> (in the dbus-spawn tests).

Just opened a new ticket for that error, see #bug 72213

> 
> The "core" D-Bus developers are incredibly unlikely to fix this.
Comment 3 Chengwei Yang 2013-12-02 12:05:37 UTC
(In reply to comment #1)
> On FreeBSD 9.1
> 
> ./../bus/bus-test: checking for memleaks
> ./../bus/bus-test: Running signals test
> ./../bus/bus-test: checking for memleaks
> ./../bus/bus-test: Running SHA1 connection test
> ./../bus/bus-test: checking for memleaks
> 2 dbus_malloc blocks were not freed
>   D-Bus not compiled with backtrace support so unable to print a backtrace
>   Process 75491 sleeping for gdb attach

I have patches for these two blocks memleak, still working on #bug 72213
Comment 4 Chengwei Yang 2013-12-03 04:55:46 UTC
Created attachment 90139 [details] [review]
[PATCH 1/3] Fix memory leak for kqueue: replace tab with space
Comment 5 Chengwei Yang 2013-12-03 04:56:13 UTC
Created attachment 90140 [details] [review]
[PATCH 2/3] Fix memory leak for kqueue: shutdown kqueue correctly
Comment 6 Chengwei Yang 2013-12-03 04:56:33 UTC
Created attachment 90141 [details] [review]
[PATCH 3/3] Fix memory leak for kqueue: free memory before assign
Comment 7 Chengwei Yang 2013-12-03 07:19:23 UTC
Created attachment 90143 [details] [review]
[PATCH v2] Fix memory leak for kqueue: shutdown kqueue correctly
Comment 8 Simon McVittie 2013-12-03 12:08:35 UTC
Comment on attachment 90139 [details] [review]
[PATCH 1/3] Fix memory leak for kqueue: replace tab with space

Review of attachment 90139 [details] [review]:
-----------------------------------------------------------------

I'll put it through "git show --ignore-space-change", but probably r+.
Comment 9 Simon McVittie 2013-12-03 12:12:21 UTC
Comment on attachment 90143 [details] [review]
[PATCH v2] Fix memory leak for kqueue: shutdown kqueue correctly

Review of attachment 90143 [details] [review]:
-----------------------------------------------------------------

> Also, it fixes other memory leaks

I don't see any non-D-Bus memory leaks here? It fixes D-Bus memory leaks, and fd leaks.

::: bus/dir-watch-kqueue.c
@@ +122,5 @@
> +      _dbus_watch_unref (watch);
> +      watch = NULL;
> +    }
> +
> +  if (kq >= 0)

Redundant with the early-return at the top.
Comment 10 Chengwei Yang 2013-12-03 12:54:23 UTC
Created attachment 90153 [details] [review]
[PATCH v3] Fix memory leak for kqueue: shutdown kqueue correctly

Update commit message and drop redundant "if (kq >= 0)" clause.
Comment 11 Simon McVittie 2014-01-06 16:31:51 UTC
Fixed in git for 1.7.10, thanks

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.