dbus crashing with no environment

Daniel P. Berrange dan at berrange.com
Tue Nov 25 07:59:53 PST 2008

On Tue, Nov 25, 2008 at 03:18:40PM +0000, Bastien Nocera wrote:
> Heya,
> I was trying to see why fprintd was crashing when using the service
> activation, and Richard mentioned that I should try clearing the
> environment as that's what the activation helper does.
> I don't actually need any environment in fprintd, so went ahead with it,
> and ended up with crashes in dbus itself. fprintd uses dbus-glib, but I
> was able to reproduce with the attached DBus-only test case.

This does not appear to be neccessarily dbus's  fault - change your
demo program to just be 

  #include <stdlib.h>

  int main (int argc, char **argv)
        clearenv ();
        return 0;

And it'll also crash & burn the same way:

==14998== Invalid read of size 4
==14998==    at 0xB3A53F: unsetenv (setenv.c:295)
==14998==    by 0x4008326: unsetenv (mc_replace_strmem.c:760)
==14998==    by 0x8048415: main (env.c:6)
==14998==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

So its arguably a bug in libc's unsetenv(), but we could guard against 
it in DBus by making the dbus_setenv do

   if (getenv("FOO")) unsetenv("FOO");

Instead of calling unsetenv() unconditionally.

|: http://berrange.com/     -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://freshmeat.net/~danielpb/    -o-   http://gtk-vnc.sourceforge.net :|
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/dbus/attachments/20081125/e184a7b5/attachment.pgp 

More information about the dbus mailing list