In Utopic importing Gdk requires $XDG_RUNTIME_DIR or $DISPLAY

Bug #1339506 reported by Christopher Lee
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pygobject (Ubuntu)
Triaged
Wishlist
Unassigned

Bug Description

When using the gi.repository bindings on Utopic a segfault occurs if an expected environment variable isn't set.

On Utopic machines we have a debian/rules build step fail due to a segfault that happens when the expected environment variables are not available.

In Trusty this only resulted in a warning (error: XDG_RUNTIME_DIR not set in the environment.)

To reproduce:
  $ env -i python3 -c "from gi.repository import Gdk"

On my Utopic machine this causes a segfault.

Martin Pitt (pitti)
summary: - In Utopic importing Gdk with no XDG_* env vars causes segfault
+ In Utopic importing Gdk requires $XDG_RUNTIME_DIR
Revision history for this message
Martin Pitt (pitti) wrote :

It's not a segfault, it's a g_error() and thus a SIGABRT. This happens in gdk_display_manager_open_display(): It iterates over all available backends, and as there is no $DISPLAY the X.org backend fails. Then it tries the wayland backend but there is no $XDG_RUNTIME_DIR either so it fails as well.

The obvious workaround here is to either run the thing under Xvfb to provide a $DISPLAY, or set $XDG_RUNTIME_DIR to some $(CURDIR)/debian/tmp during package build. But of course in the latter case Gdk won't actually do anything. So if you import Gdk to use it, I'd rather recommend xvfb.

So for GDK this is pretty much a wontfix. If we keep this open, then against pygobject, as its Gdk overrides trigger the initialization of GTK/GDK on import. This is mostly due to being backwards compatible with PyGTK, and all Python code out there which uses Gtk/Gdk expects this, and doesn't call Gdk.init()/Gtk.init() explicitly. So the wishlist bug would be to not try and initialize Gdk if there's no DISPLAY or runtime dir, but that's really not something which we want to carry downstream.

summary: - In Utopic importing Gdk requires $XDG_RUNTIME_DIR
+ In Utopic importing Gdk requires $XDG_RUNTIME_DIR or $DISPLAY
affects: gtk+3.0 (Ubuntu) → ubuntu
affects: ubuntu → pygobject (Ubuntu)
Changed in pygobject (Ubuntu):
status: New → Triaged
importance: Undecided → Wishlist
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.