Debian Bug report logs - #697402
bzr-gtk: causes crash in pydoc -k when python-gtk2 is also installed

Package: python; Maintainer for python is Matthias Klose <doko@debian.org>; Source for python is src:python-defaults.

Reported by: Samuel Bronson <naesten@gmail.com>

Date: Fri, 4 Jan 2013 21:24:02 UTC

Severity: important

Merged with 703786

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, naesten@gmail.com, Debian QA Group <packages@qa.debian.org>:
Bug#697402; Package bzr-gtk. (Fri, 04 Jan 2013 21:24:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Samuel Bronson <naesten@gmail.com>:
New Bug report received and forwarded. Copy sent to naesten@gmail.com, Debian QA Group <packages@qa.debian.org>. (Fri, 04 Jan 2013 21:24:05 GMT) Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Samuel Bronson <naesten@gmail.com>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: bzr-gtk: causes crash in pydoc -k when python-gtk2 is also installed
Date: Fri, 04 Jan 2013 16:20:42 -0500
[Message part 1 (text/plain, inline)]
Package: bzr-gtk
Version: 0.103.0+bzr792-3
Severity: critical

Dear Maintainer,

Having bzr-gtk and python-gtk2 installed at the same time causes "pydoc
-k foobarbaz" to crash, because

  1) pydoc has to import all packages in order to find out what modules
  they contain

  2) your package bzrlib.plugins.gtk.branchview causes gi.repository.Gtk
  to be imported

  3) python-gtk2's package gtk imports _gtk

  4) importing both of those modules causes a SIGSEGV

Anyone hoping to take a look at the crash itself might (or might not)
find this script helpful:

[pydoc-crash-repro.py (text/plain, inline)]
import sys
import resource
#import pkgutil

# A big stack wastes time/space in GDB.
# (This size was chosen for i386; adjust as needed.)
resource.setrlimit(resource.RLIMIT_STACK, (32*1024, -1))

# import bzrlib.plugins.gtk.branchview
from gi.repository import Gtk
import _gtk

#for importer, modname, ispkg in pkgutil.walk_packages():
#    print modname, ispkg, importer
#    sys.stdout.flush()
[Message part 3 (text/plain, inline)]
This is marked critical ONLY because having your package installed
causes "pydoc -k" to fail, not because I think you're actually to blame
for this: the ultimate problem is 4) above, which is of course a problem
with python-gi and python-gtk2; bzr-gtk just exposes this booby-trap to
"pydoc -k".

I would report a bug for that, too, but I don't know which package to
report it against :-(.


P.S. This would have been easier to debug if the python in wheezy had
debug syms available <http://bugs.debian.org/681348>.

Thanks to Jakub Wilk for building me a python with the patch I posted on
<http://paste.debian.net/220873/>: maybe all I got out of valgrind was
the fact that it was a stack overflow, but having debug symbols was
*vital*.

-- System Information:
Debian Release: 7.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages bzr-gtk depends on:
ii  bzr                      2.6.0~bzr6526-1
ii  gir1.2-gconf-2.0         3.2.5-1+build1
ii  gir1.2-gtk-3.0           3.4.2-4
ii  gir1.2-gtksource-3.0     3.4.2-1
ii  libcanberra-gtk3-module  0.28-6
ii  python                   2.7.3~rc2-1
ii  python-gi                3.2.2-1
ii  python2.6                2.6.8-0.2
ii  python2.7                2.7.3~rc2-2.1+valgrind

Versions of packages bzr-gtk recommends:
ii  bzr-dbus            0.1~bzr52-2
ii  gir1.2-freedesktop  1.32.1-1
ii  gir1.2-notify-0.7   0.7.5-1
ii  python-gi-cairo     3.2.2-1
pn  seahorse            <none>

Versions of packages bzr-gtk suggests:
ii  bzr-loom    2.2.0-2
pn  bzr-search  <none>

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!

Added indication that 697402 affects python2.7 Request was from Samuel Bronson <naesten@gmail.com> to control@bugs.debian.org. (Sun, 06 Jan 2013 02:03:08 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Debian QA Group <packages@qa.debian.org>:
Bug#697402; Package bzr-gtk. (Sun, 06 Jan 2013 02:42:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andrey Rahmatullin <wrar@wrar.name>:
Extra info received and forwarded to list. Copy sent to Debian QA Group <packages@qa.debian.org>. (Sun, 06 Jan 2013 02:42:05 GMT) Full text and rfc822 format available.

Message #12 received at 697402@bugs.debian.org (full text, mbox):

From: Andrey Rahmatullin <wrar@wrar.name>
To: Samuel Bronson <naesten@gmail.com>, 697402@bugs.debian.org
Subject: Re: Bug#697402: bzr-gtk: causes crash in pydoc -k when python-gtk2 is also installed
Date: Sun, 6 Jan 2013 08:37:52 +0600
[Message part 1 (text/plain, inline)]
On Fri, Jan 04, 2013 at 04:20:42PM -0500, Samuel Bronson wrote:
>   2) your package bzrlib.plugins.gtk.branchview causes gi.repository.Gtk
>   to be imported
Which loads libgtk-3.so.0

>   3) python-gtk2's package gtk imports _gtk
Which loads libgtk-x11-2.0.so.0

>   4) importing both of those modules causes a SIGSEGV
Because unless I'm missing something gtk2 and gtk3 shared libs have common
symbols on the default interface so you cannot load and use them in one
process.
Apparently pydoc doesn't crash without bzr-gtk because gi.repository.Gtk
is a "virtual" module, resolved in the runtime, so pydoc doesn't know
about it.

-- 
WBR, wRAR
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian QA Group <packages@qa.debian.org>:
Bug#697402; Package bzr-gtk. (Thu, 24 Jan 2013 22:51:03 GMT) Full text and rfc822 format available.

Message #15 received at 697402@bugs.debian.org (full text, mbox):

From: Jakub Wilk <jwilk@debian.org>
To: 697402@bugs.debian.org
Subject: Re: Bug#697402: bzr-gtk: causes crash in pydoc -k when python-gtk2 is also installed
Date: Thu, 24 Jan 2013 23:48:04 +0100
* Samuel Bronson <naesten@gmail.com>, 2013-01-04, 16:20:
>from gi.repository import Gtk
>import _gtk

The last line should read:
from import _gtk


This bug should be reassigned somewhere else, but I haven't decided 
where yet. Anyway, here are some ideas how to fix (or "fix") it:

1) Make pydoc more robust. It could spawn a worker process, which would 
do all the nasty import job. If the worked process segfaulted, it 
wouldn't be a big deal, as a new one could be spawned.

2) Fix both python-gtk2 and python-gi, so that ImportError is thrown 
early if you try to load Gtk$n bindings and Gtk$((5-n)) are already in 
sys.modules. This should be easy to do on the python-gtk2 side, and 
probably way more tricky on the python-gi side. Also, this solves the 
problem only partially, because there are other Python extensions linked 
to libgtk2 or libgtk3. (Certainly too many too fix them all. :/)

3) Make libgtk2 and libgtk3 use symbol versioning. Probably not 
something that would be accepted for wheezy. :/

-- 
Jakub Wilk



Information forwarded to debian-bugs-dist@lists.debian.org, Debian QA Group <packages@qa.debian.org>:
Bug#697402; Package bzr-gtk. (Thu, 24 Jan 2013 23:21:03 GMT) Full text and rfc822 format available.

Message #18 received at 697402@bugs.debian.org (full text, mbox):

From: Jakub Wilk <jwilk@debian.org>
To: 697402@bugs.debian.org
Subject: Re: Bug#697402: bzr-gtk: causes crash in pydoc -k when python-gtk2 is also installed
Date: Fri, 25 Jan 2013 00:17:41 +0100
* Jakub Wilk <jwilk@debian.org>, 2013-01-24, 23:48:
>>from gi.repository import Gtk
>>import _gtk
>The last line should read:
>from import _gtk

Third time lucky:
from gtk import _gtk

-- 
Jakub Wilk



Information forwarded to debian-bugs-dist@lists.debian.org, Debian QA Group <packages@qa.debian.org>:
Bug#697402; Package bzr-gtk. (Sat, 26 Jan 2013 11:00:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matthew Woodcraft <matthew@woodcraft.me.uk>:
Extra info received and forwarded to list. Copy sent to Debian QA Group <packages@qa.debian.org>. (Sat, 26 Jan 2013 11:00:03 GMT) Full text and rfc822 format available.

Message #23 received at 697402@bugs.debian.org (full text, mbox):

From: Matthew Woodcraft <matthew@woodcraft.me.uk>
To: 697402@bugs.debian.org
Subject: Re: bzr-gtk: causes crash in pydoc -k when python-gtk2 is also installed
Date: Sat, 26 Jan 2013 10:29:27 +0000
Debian has in the past contained Python packages which have side-effects
when imported which are worse than just crashing the calling process
(for example, I've had pydoc crash my window manager).

Arguably all such cases are bugs in those packages, but it seems likely
that such bugs will appear again. And of course the user might have
local Python packages which do dangerous things when imported.

So I think pydoc is just wrong to believe it can safely call
pkgutil.walk_packages() with no explicit path.

(This behaviour can be particularly entertaining when combined with
zsh's tab-completion for 'python -m', which currently calls pydoc in a
similar way [#691638].)

-M-



Information forwarded to debian-bugs-dist@lists.debian.org, Debian QA Group <packages@qa.debian.org>:
Bug#697402; Package bzr-gtk. (Sat, 26 Jan 2013 12:39:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Julien Cristau <jcristau@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian QA Group <packages@qa.debian.org>. (Sat, 26 Jan 2013 12:39:08 GMT) Full text and rfc822 format available.

Message #28 received at 697402@bugs.debian.org (full text, mbox):

From: Julien Cristau <jcristau@debian.org>
To: Matthew Woodcraft <matthew@woodcraft.me.uk>, 697402@bugs.debian.org
Cc: python@packages.debian.org
Subject: Re: Bug#697402: bzr-gtk: causes crash in pydoc -k when python-gtk2 is also installed
Date: Sat, 26 Jan 2013 12:36:50 +0000
[Message part 1 (text/plain, inline)]
Control: reassign -1 python
Control: severity -1 important

On Sat, Jan 26, 2013 at 10:29:27 +0000, Matthew Woodcraft wrote:

> Debian has in the past contained Python packages which have side-effects
> when imported which are worse than just crashing the calling process
> (for example, I've had pydoc crash my window manager).
> 
> Arguably all such cases are bugs in those packages, but it seems likely
> that such bugs will appear again. And of course the user might have
> local Python packages which do dangerous things when imported.
> 
> So I think pydoc is just wrong to believe it can safely call
> pkgutil.walk_packages() with no explicit path.
> 
> (This behaviour can be particularly entertaining when combined with
> zsh's tab-completion for 'python -m', which currently calls pydoc in a
> similar way [#691638].)
> 
This is clearly not a bzr-gtk bug, and critical seems over the top, so
downgrading and moving to python, which ships pydoc.

Cheers,
Julien
[signature.asc (application/pgp-signature, inline)]

Bug reassigned from package 'bzr-gtk' to 'python'. Request was from Julien Cristau <jcristau@debian.org> to 697402-submit@bugs.debian.org. (Sat, 26 Jan 2013 12:39:08 GMT) Full text and rfc822 format available.

No longer marked as found in versions bzr-gtk/0.103.0+bzr792-3. Request was from Julien Cristau <jcristau@debian.org> to 697402-submit@bugs.debian.org. (Sat, 26 Jan 2013 12:39:08 GMT) Full text and rfc822 format available.

Severity set to 'important' from 'critical' Request was from Julien Cristau <jcristau@debian.org> to 697402-submit@bugs.debian.org. (Sat, 26 Jan 2013 12:39:09 GMT) Full text and rfc822 format available.

Added tag(s) moreinfo. Request was from Sebastian Ramacher <sramacher@debian.org> to 703786-submit@bugs.debian.org. (Sat, 23 Mar 2013 19:39:07 GMT) Full text and rfc822 format available.

Merged 697402 703786 Request was from Sebastian Ramacher <sramacher@debian.org> to 703786-submit@bugs.debian.org. (Sat, 23 Mar 2013 19:39:08 GMT) Full text and rfc822 format available.

Removed tag(s) moreinfo. Request was from Sebastian Ramacher <sramacher@debian.org> to control@bugs.debian.org. (Sat, 23 Mar 2013 19:45:08 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Thu Apr 24 04:40:59 2014; Machine Name: buxtehude.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.