[PyQt] Bug report: multiple QApplication instances cause a segfault

Algis Kabaila akabaila at pcug.org.au
Thu Jun 23 12:26:02 BST 2011


On Thu, 23 Jun 2011 07:06:49 PM Hans-Peter Jansen wrote:
> On Thursday 23 June 2011, 08:28:06 David Townshend wrote:
> > If it vanishes, it implies a segfault which you will probably see if
> > you run idle form the command line. You should be able to get a
> > backtrace by running idle through gdb, i.e, from the command line,
> > run "gdb idle". Then in gdb type "run". Idle should start as usual,
> > so get it to crash.  Then within gdb type "bt". This will give a
> > backtrace which will hopefully at least point to whether its python,
> > pyqt or qt.
> 
> Close, but no cigar.
> 
> after installing assorted .debug packages of python(3), sip, qt, PyQt,
> and probably glibc, glib, libstdc++, you usually invoke a python script
> with gdb similar to:
> 
> gdb python3 -ex "set args /usr/bin/idle" -ex run
> 
> Hth,
> Pete

Hi Pete, David et al,

I know "sweet all" about the gdb, so will need to read up on it (at least a 
little bit).  I  put in the CLI your command and attach the listing, warts and 
all.  It does not tell *me* much, so I list it all below.  You will see that 
idle could not be found at the location suggested, so I ran it with the 
command that IDLE gui had in the properties.  So IDLE did start ok and it 
failed after the entry of the same commands under (gdb) as has been tried on 
idle window earlier (without invoking gdb):

>>> from PyQt4 import QtGui
>>> app = QtGui.QApplication([])
>>> app.quit()
>>> app = QtGui.QApplication([])
>>> app.quit()  <-- frozen text in IDLE Python Shell.

At  this point "bt" command was entered within the gdb shell.  As expected 
there are segmentation faults. The following are the "grim details":

******************
ak at supremo:~$ gdb python3 -ex "set args /usr/bin/idle" -ex run
Starting program: /usr/bin/python3 /usr/bin/idle
[Thread debugging using libthread_db enabled]
/usr/bin/python3: can't open file '/usr/bin/idle': [Errno 2] No such file or 
directory
Program exited with code 02.
(gdb) /usr/bin/idle-python3.2 -n
Undefined command: "".  Try "help".
(gdb) run /usr/bin/idle-python3.2 -n
Starting program: /usr/bin/python3 /usr/bin/idle-python3.2 -n
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffef1cd700 (LWP 1705)]

Program received signal SIGSEGV, Segmentation fault.
0x00007fffec894b1f in ?? () from /usr/lib/libQtGui.so.4
(gdb) bt
#0  0x00007fffec894b1f in ?? () from /usr/lib/libQtGui.so.4
#1  0x00007ffff053ad3f in _XError () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007ffff0537fb1 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#3  0x00007ffff0538aa6 in _XReply () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#4  0x00007ffff052e48d in XQueryTree () from /usr/lib/x86_64-linux-
gnu/libX11.so.6
#5  0x00007ffff0b8a246 in Tk_HandleEvent () from /usr/lib/libtk8.5.so.0
#6  0x00007ffff0b8a7c0 in ?? () from /usr/lib/libtk8.5.so.0
#7  0x00007ffff08d564f in Tcl_ServiceEvent () from /usr/lib/libtcl8.5.so.0
#8  0x00007ffff08d58d5 in Tcl_DoOneEvent () from /usr/lib/libtcl8.5.so.0
#9  0x00007ffff11ba2e9 in ?? () from /usr/lib/python3.2/lib-
dynload/_tkinter.cpython-32mu.so
#10 0x0000000000465d28 in call_function (f=<value optimised out>, 
throwflag=<value optimised out>)
    at ../Python/ceval.c:3875
#11 PyEval_EvalFrameEx (f=<value optimised out>, throwflag=<value optimised 
out>)
    at ../Python/ceval.c:2673
#12 0x00000000004675f2 in PyEval_EvalCodeEx (_co=<value optimised out>, 
globals=<value optimised out>, 
    locals=<value optimised out>, args=<value optimised out>, argcount=1, 
kws=0x12a0d40, kwcount=0, 
    defs=0xe76b68, defcount=1, kwdefs=0x0, closure=0x0) at 
../Python/ceval.c:3311
#13 0x0000000000466784 in fast_function (f=<value optimised out>, 
throwflag=<value optimised out>)
    at ../Python/ceval.c:3973
#14 call_function (f=<value optimised out>, throwflag=<value optimised out>) at 
../Python/ceval.c:3896
#15 PyEval_EvalFrameEx (f=<value optimised out>, throwflag=<value optimised 
out>)
    at ../Python/ceval.c:2673
#16 0x0000000000466ae0 in fast_function (f=<value optimised out>, 
throwflag=<value optimised out>)
    at ../Python/ceval.c:3963
#17 call_function (f=<value optimised out>, throwflag=<value optimised out>) at 
../Python/ceval.c:3896
#18 PyEval_EvalFrameEx (f=<value optimised out>, throwflag=<value optimised 
out>)
    at ../Python/ceval.c:2673
#19 0x00000000004675f2 in PyEval_EvalCodeEx (_co=<value optimised out>, 
globals=<value optimised out>, 
    locals=<value optimised out>, args=<value optimised out>, argcount=0, 
kws=0x0, kwcount=0, defs=0x0, 
    defcount=0, kwdefs=0x0, closure=0x0) at ../Python/ceval.c:3311
#20 0x000000000046787b in PyEval_EvalCode (co=<value optimised out>, 
globals=<value optimised out>, 
    locals=<value optimised out>) at ../Python/ceval.c:761
#21 0x000000000048d00d in run_mod (fp=0xb149b0, filename=<value optimised out>, 
    start=<value optimised out>, globals=
    {'QtGui': <module at remote 0x1970878>, '__builtins__': <module at remote 
0x7ffff7fb2638>, '__file__'---Type <return> to continue, or q <return> to quit---
q
Quit
(gdb) quit
A debugging session is active.

        Inferior 1 [process 1704] will be killed.

Quit anyway? (y or n) y
ak at supremo:~$ 
ak at supremo:~$ gdb python3 -ex "set args /usr/bin/idle" -ex run
Starting program: /usr/bin/python3 /usr/bin/idle
[Thread debugging using libthread_db enabled]
/usr/bin/python3: can't open file '/usr/bin/idle': [Errno 2] No such file or 
directory
Program exited with code 02.
(gdb) /usr/bin/idle-python3.2 -n
Undefined command: "".  Try "help".
(gdb) run /usr/bin/idle-python3.2 -n
Starting program: /usr/bin/python3 /usr/bin/idle-python3.2 -n
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffef1cd700 (LWP 1705)]

Program received signal SIGSEGV, Segmentation fault.
0x00007fffec894b1f in ?? () from /usr/lib/libQtGui.so.4
(gdb) bt
#0  0x00007fffec894b1f in ?? () from /usr/lib/libQtGui.so.4
#1  0x00007ffff053ad3f in _XError () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007ffff0537fb1 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#3  0x00007ffff0538aa6 in _XReply () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#4  0x00007ffff052e48d in XQueryTree () from /usr/lib/x86_64-linux-
gnu/libX11.so.6
#5  0x00007ffff0b8a246 in Tk_HandleEvent () from /usr/lib/libtk8.5.so.0
#6  0x00007ffff0b8a7c0 in ?? () from /usr/lib/libtk8.5.so.0
#7  0x00007ffff08d564f in Tcl_ServiceEvent () from /usr/lib/libtcl8.5.so.0
#8  0x00007ffff08d58d5 in Tcl_DoOneEvent () from /usr/lib/libtcl8.5.so.0
#9  0x00007ffff11ba2e9 in ?? () from /usr/lib/python3.2/lib-
dynload/_tkinter.cpython-32mu.so
#10 0x0000000000465d28 in call_function (f=<value optimised out>, 
throwflag=<value optimised out>)
    at ../Python/ceval.c:3875
#11 PyEval_EvalFrameEx (f=<value optimised out>, throwflag=<value optimised 
out>)
    at ../Python/ceval.c:2673
#12 0x00000000004675f2 in PyEval_EvalCodeEx (_co=<value optimised out>, 
globals=<value optimised out>, 
    locals=<value optimised out>, args=<value optimised out>, argcount=1, 
kws=0x12a0d40, kwcount=0, 
    defs=0xe76b68, defcount=1, kwdefs=0x0, closure=0x0) at 
../Python/ceval.c:3311
#13 0x0000000000466784 in fast_function (f=<value optimised out>, 
throwflag=<value optimised out>)
    at ../Python/ceval.c:3973
#14 call_function (f=<value optimised out>, throwflag=<value optimised out>) at 
../Python/ceval.c:3896
#15 PyEval_EvalFrameEx (f=<value optimised out>, throwflag=<value optimised 
out>)
    at ../Python/ceval.c:2673
#16 0x0000000000466ae0 in fast_function (f=<value optimised out>, 
throwflag=<value optimised out>)
    at ../Python/ceval.c:3963
#17 call_function (f=<value optimised out>, throwflag=<value optimised out>) at 
../Python/ceval.c:3896
#18 PyEval_EvalFrameEx (f=<value optimised out>, throwflag=<value optimised 
out>)
    at ../Python/ceval.c:2673
#19 0x00000000004675f2 in PyEval_EvalCodeEx (_co=<value optimised out>, 
globals=<value optimised out>, 
    locals=<value optimised out>, args=<value optimised out>, argcount=0, 
kws=0x0, kwcount=0, defs=0x0, 
    defcount=0, kwdefs=0x0, closure=0x0) at ../Python/ceval.c:3311
#20 0x000000000046787b in PyEval_EvalCode (co=<value optimised out>, 
globals=<value optimised out>, 
    locals=<value optimised out>) at ../Python/ceval.c:761
#21 0x000000000048d00d in run_mod (fp=0xb149b0, filename=<value optimised out>, 
    start=<value optimised out>, globals=
    {'QtGui': <module at remote 0x1970878>, '__builtins__': <module at remote 
0x7ffff7fb2638>, '__file__'---Type <return> to continue, or q <return> to quit---
q
Quit
(gdb) quit
A debugging session is active.

        Inferior 1 [process 1704] will be killed.

Quit anyway? (y or n) y
ak at supremo:~$ 
******************

Personally, I have no worries about it all as I do use eric5 (and like it).  I 
think that IDLE with Python3 is not entirely without problems. To think is one 
thing, the evidence is another...

OldAl.


More information about the PyQt mailing list