Bug 989 - Memory leak in system bus
Summary: Memory leak in system bus
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: low normal
Assignee: Havoc Pennington
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-05 06:22 UTC by Kimmo Hämäläinen
Modified: 2006-08-01 10:26 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Test server and client + conf and service files + valgrind.out (34.93 KB, application/octet-stream)
2004-08-05 06:24 UTC, Kimmo Hämäläinen
Details
Patch to fix the memory leak (283 bytes, patch)
2004-08-05 06:27 UTC, Kimmo Hämäläinen
Details | Splinter Review
alternative patch (615 bytes, patch)
2004-08-06 16:32 UTC, Olivier Andrieu
Details | Splinter Review

Description Kimmo Hämäläinen 2004-08-05 06:22:20 UTC
Memory leak in CVS version of D-BUS, dated 5th Aug 2004.
I made a simple server and client. The server was not running, the system bus
was running in Valgrind v2.1.1 and the idea was to activate the server by
sending a message with the auto-activate flag set. Strangely the auto-activation
didn't work at all, perhaps I did something wrong, so I only report the memleak
for now.

Steps done:
kihamala@mylly:~/dbus-test/memleak-progs$ sudo valgrind --suppressions=/usr/lib/
valgrind/default.supp -v --leak-check=yes --trace-children=yes --logfile=/tmp/va
lgrind.out --num-callers=10 /home/kihamala/dbus040805-prefix/bin/dbus-daemon-1 -
-config-file=/home/kihamala/dbus040805-prefix/etc/dbus-1/system.conf --print-add
ress &
[2] 11338
kihamala@mylly:~/dbus-test/memleak-progs$ unix:path=/home/kihamala/dbus040805-pr
efix/var/run/dbus/system_bus_socket

kihamala@mylly:~/dbus-test/memleak-progs$ ldd bug_client
                libdbus-1.so.0 => /home/kihamala/dbus040805-prefix/lib/libdbus-1
.so.0 (0x40018000)
        libdbus-glib-1.so.0 => /home/kihamala/dbus040805-prefix/lib/libdbus-glib
-1.so.0 (0x4007c000)
        libc.so.6 => /lib/tls/libc.so.6 (0x40093000)
        libnsl.so.1 => /lib/tls/libnsl.so.1 (0x401ce000)
        libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x401e3000)
        libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x4021c000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
kihamala@mylly:~/dbus-test/memleak-progs$ ldd ../bug_svc
                libdbus-1.so.0 => /home/kihamala/dbus040805-prefix/lib/libdbus-1
.so.0 (0x40018000)
        libdbus-glib-1.so.0 => /home/kihamala/dbus040805-prefix/lib/libdbus-glib
-1.so.0 (0x4007c000)
        libc.so.6 => /lib/tls/libc.so.6 (0x40093000)
        libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x401ce000)
        libnsl.so.1 => /lib/tls/libnsl.so.1 (0x4024d000)
        libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x40262000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
kihamala@mylly:~/dbus-test/memleak-progs$ ./bug_client 
service bug.svc does not exist
message 1 was put into the queue
Messages flushed
kihamala@mylly:~/dbus-test/memleak-progs$ Fd 4 did not have the close-on-exec fl
ag set!
Fd 5 did not have the close-on-exec flag set!

kihamala@mylly:~/dbus-test/memleak-progs$ ps xau | grep dbus
message  11338  2.5  0.7 1499224 14676 pts/0 S    15:49   0:01 /usr/bin/valgrind
.bin --suppressions=/usr/lib/valgrind/default.supp -v --leak-check=yes --trace-c
hildren=yes --logfile=/tmp/valgrind.out --num-callers=10 /home/kihamala/dbus0408
05-prefix/bin/dbus-daemon-1 --config-file=/home/kihamala/dbus040805-prefix/etc/d
bus-1/system.conf --print-address
kihamala 11352  0.0  0.0  1576  464 pts/0    S+   15:50   0:00 grep dbus

Valgrind detected a memory leak:
==11347== 33 bytes in 1 blocks are definitely lost in loss record 2 of 10
==11347==    at 0x3C01FD01: realloc (vg_replace_malloc.c:162)
==11347==    by 0x808D732: dbus_realloc (dbus-memory.c:589)
==11347==    by 0x80921FF: reallocate_for_length (dbus-string.c:395)
==11347==    by 0x809227B: set_length (dbus-string.c:421)
==11347==    by 0x8094B48: _dbus_string_append_printf_valist (dbus-string.c:1027
)
==11347==    by 0x806AA80: dbus_set_error (dbus-errors.c:347)
==11347==    by 0x80A0CFB: _dbus_stat (dbus-sysdeps.c:2961)
==11347==    by 0x804CE7B: process_config_first_time_only (bus.c:290)
==11347==    by 0x804D544: load_config (bus.c:520)
==11347==    by 0x804D72E: bus_context_new (bus.c:586)
Comment 1 Kimmo Hämäläinen 2004-08-05 06:24:53 UTC
Created attachment 575 [details]
Test server and client + conf and service files + valgrind.out
Comment 2 Kimmo Hämäläinen 2004-08-05 06:27:21 UTC
Created attachment 576 [details] [review]
Patch to fix the memory leak

Tested this by applying the patch, recompiling, reinstalling and rerunning
under Valgrind.
Comment 3 Olivier Andrieu 2004-08-06 16:31:27 UTC
(In reply to comment #2)
> Created an attachment (id=576)
> Patch to fix the memory leak

Right, thanks. Actually, the tmp_error is not needed at all, so we might as well
get rid of it.
Comment 4 Olivier Andrieu 2004-08-06 16:32:16 UTC
Created attachment 584 [details] [review]
alternative patch
Comment 5 Havoc Pennington 2004-08-07 17:13:30 UTC
Comment on attachment 584 [details] [review]
alternative patch

Looks good, thanks
Comment 6 Olivier Andrieu 2004-09-13 02:27:04 UTC
Kimmo, do you still have problems with the auto-activation or can we close this
bug ?
Comment 7 Kimmo Hämäläinen 2004-09-13 06:04:59 UTC
I guess we can close this because I tested it in Comment #2. We can always
reopen this or file new bugs if there's problems...


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.