PSA: fork() after gtk_init() is unsafe.
sidnioulz at gmail.com
Mon May 5 02:17:14 CEST 2014
Thanks again Alistair for these reports!
I totally agree with you. Forking (rightfully) breaks DBus connections
among other things, and we can't tell who's been putting DBus in which of
the libs we're using -- better safe than sorry. :)
2014-05-04 23:55 GMT+01:00 Alistair Buxton <a.j.buxton at gmail.com>:
> Hi all,
> It has recently come to my attention that a lot of the programs in
> Xfce that have a daemon mode call gtk_init() before fork()ing. This is
> unsafe, and when it goes wrong this will typically manifest as the
> daemon hanging shortly after forking, and appearing to simply do
> nothing at all.
> Some examples of this bug:
> I also suspect this might be the cause of all the weird thunar
> crashes, but I have no evidence for this currently.
> So you're probably going to say "but Al, those are all Xubuntu
> specific bugs caused by Ubuntu modifications" - while this is true, we
> believe the underlying cause of all of them is the fork() after
> gtk_init(). The modded Gtk stuff in Ubuntu merely exposes the problem.
> fork() after gtk_init() has always been problematic, and the only
> reason it works is by luck - or at least, that is what our research
> into the problem has told us. For example:
> So if you're maintaining an application in Xfce that forks in order to
> become a daemon, please do it as early on as possible. It isn't
> necessary to call gtk_init() to parse arguments with glib, so ideally
> you would parse for the "no-daemon" argument, possibly fork, then call
> gtk_init, then do everything else. This is the order of operations in
> the fix I proposed for xfce4-volumed-pulse. Note that the original
> xfce4-volumed isn't affected by this bug, but potentially there could
> be others I haven't mentioned.
> Alistair Buxton
> a.j.buxton at gmail.com
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
PhD Student in Information Security
University College London
Free Software Developer
OpenPGP : 1B6B1670
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Xfce4-dev