[Debconf-devel] Bug#690776: debconf can crash if gtk2 fails to import into Perl

James Hunt james.hunt at ubuntu.com
Wed Oct 17 13:17:22 UTC 2012


Package: debconf
Version: 1.5.46
Severity: normal
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu quantal ubuntu-patch

Dear Maintainers,

The attached patch, although too late to apply to Ubuntu Quantal,
addresses the issue shown in Ubuntu bug 1060249:

https://bugs.launchpad.net/ubuntu/+source/debconf/+bug/1060249

It will stop debconf from crashing should 'use Gtk2;' fail, and allow it
to gracefully fall back to other frontends as designed.

  * Debconf/Frontend/Gnome.pm:init(): Only 'use Gtk2;' once it has been
    proven to be safe to avoid rogue Perl module behaviour from crashing
    debconf (#LP: 1060249).

Thanks for considering the patch.

-- System Information:
Debian Release: wheezy/sid
  APT prefers quantal-updates
  APT policy: (500, 'quantal-updates'), (500, 'quantal-security'), (500,
'quantal')
Architecture: i386 (i686)

Kernel: Linux 3.5.0-17-generic (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Kind regards,

James.
--
James Hunt
____________________________________
http://upstart.ubuntu.com/cookbook
http://upstart.ubuntu.com/cookbook/upstart_cookbook.pdf
-------------- next part --------------
=== modified file 'Debconf/FrontEnd/Gnome.pm'
--- Debconf/FrontEnd/Gnome.pm	2011-06-23 06:52:13 +0000
+++ Debconf/FrontEnd/Gnome.pm	2012-10-12 19:35:29 +0000
@@ -14,13 +14,6 @@
 use Debconf::Encoding qw(to_Unicode);
 use base qw{Debconf::FrontEnd};
 
-# Catch this so as not to confuse the poor users if Gtk or Gnome are not
-# installed.
-eval q{
-	use Gtk2;
-};
-die "Unable to load Gtk -- is libgtk2-perl installed?\n" if $@;
-
 =head1 DESCRIPTION
 
 This FrontEnd is a Gnome UI for Debconf.
@@ -121,11 +114,35 @@
 		}
 	}
 	else {
+		# Catch scenario where Gtk/Gnome are not installed.
+		use Gtk2;
+
 		@ARGV=@ARGV_for_gnome; # temporary change at first
 		Gtk2->init;
+
+		# Create a window, but don't show it.
+		#
+		# This has the effect of exercising gtk a bit in an
+		# attempt to force an error either in the gtk bindings
+		# themselves, but hopefully also in
+		# gtk/glib/gsettings/etc. There is no guarantee that
+		# this alone will provoke an error, but it's a
+		# relatively safe and reasonable operation to perform
+		# and further reduces the chance of the parent debconf
+		# process ending up in an unrecoverable state.
+		my $window = Gtk2::Window->new('toplevel');
+
 		exit(0); # success
 	}
 	
+	# Only load Gtk after the child has successfully proved it can do
+	# the same. This avoids the problem where a module calls into a
+	# native library and causes the perl interpreter to crash. When
+	# we get to here, we know that the child didn't crash, so it
+	# should be safe for us to attempt it.
+	eval q{use Gtk2;};
+	die "Unable to load Gtk -- is libgtk2-perl installed?\n" if $@;
+
 	my @gnome_sucks=@ARGV;
 	@ARGV=@ARGV_for_gnome;
 	Gtk2->init;

=== modified file 'debian/changelog'



More information about the Debconf-devel mailing list