From: Gelonida on
Hi Guys,
I'm desperate. I'm having a real application, which fails rather often
when finishing it. I'm not sure, whether any serious problem could be
hidden behind it

The script is a pyqt script, which segfaults most of the time on my
ubuntu 10.4 linux 64 bit and I'm having trouble to understand why.

Trying to create the smallest possible test case I ended up with
following script, which I named dodo.py and which i made executable with
chmod +x ./dodo.py

#!/usr/bin/env python
from PyQt4.QtGui import
QDialog,QGridLayout,QLabel,QComboBox,QPushButton,QApplication
a = "one"
b = "unused"
c = "also unused"
d= "ans also unused"
e = "another var"
f = "something"
class MyForm(QDialog):
def __init__(self,parent=None,config=None,ini_info=None):
super(MyForm,self).__init__(parent=parent)
grid = QGridLayout()
quit_btn = QPushButton("Quit")
quit_btn.clicked.connect(self.quit)
grid.addWidget(quit_btn,0,0)
name = "a_name"
vals_box = QComboBox()
vals_box.addItem("one")
vals_box.addItem("two")
grid.addWidget(vals_box,0,1)
self.setLayout(grid)
def quit(self):
self.close()
if __name__ == "__main__":
app = QApplication([])
myform = MyForm()
myform.show()
retcode = app.exec_()
print "last"



In order to perform the test several times I typed on the command line:

a="" ; while [ "$a" = "" ] ; do ./dodo.py ; read -t 1 a ; done

As soon as the window shows up
I click twice (slowly ) on 'one' and then on quit.

Sample output can be seen here:
gelonida(a)mypc:/my/directory$ a="" ; while [ "$a" = "" ] ; do ./dodo.py ;
read -t 1 a ; done
last
last
Segmentation fault
last
last
Segmentation fault
last
Segmentation fault
last
Segmentation fault
last
last
last
last
last
Segmentation fault
last
last
Segmentation fault
last
Segmentation fault


as you see the segfault happens rather often.

Does anybody see something suspicious with my code?
Can anybody else reproduce this?
as soon as I remove more lines the error seems to disappear.

What else could I do to debug this issue?

thanks for help or other ideas



If I run my script with strace ./dodo.py
I get following last lines for a run without error
> rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f65d6b3b8f0}, {0x4d9820, [], SA_RESTORER, 0x7f65d6b3b8f0}, 8) = 0
> munmap(0x7f65c6344000, 622280) = 0
> brk(0x2d71000) = 0x2d71000
> poll([{fd=7, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=7, revents=POLLIN|POLLOUT}])
> read(7, "\22\0\233\6\2\0\300\5\2\0\300\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 384
> writev(7, [{"\232\7\2\0\210\0\300\0056\0\2\0\207\0\300\5<\0\2\0\211\0\300\5\232\7\2\0s\0\300\5"..., 540}, {NULL, 0}, {"", 0}], 3) = 540
> poll([{fd=7, events=POLLIN}], 1, -1) = 1 ([{fd=7, revents=POLLIN}])
> read(7, "\34\0\241\6r\0\300\5\234\1\0\0\377\261\220\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 1472
> read(7, 0x29fa704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
> poll([{fd=7, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=7, revents=POLLOUT}])
> writev(7, [{"O\7\2\0\1\0\300\5<\0\2\0\0\0\300\5+\0\1\0", 20}, {NULL, 0}, {"", 0}], 3) = 20
> poll([{fd=7, events=POLLIN}], 1, -1) = 1 ([{fd=7, revents=POLLIN}])
> read(7, "\1\2\333\6\0\0\0\0\5\0\300\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096) = 32
> read(7, 0x29fa704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
> close(7) = 0
> write(19, "\1\v\3\200\1\0\0\0\0\0\0\0\t\0\0\0", 16) = 16
> close(19) = 0
> open("/proc/stat", O_RDONLY|O_CLOEXEC) = 7
> read(7, "cpu 59482 54 13580 7506040 4761"..., 8192) = 2439
> close(7) = 0
> writev(15, [{"GIOP\1\2\1\5\0\0\0\0", 12}], 1) = 12
> close(15) = 0
> writev(13, [{"GIOP\1\2\1\5\0\0\0\0", 12}], 1) = 12
> close(13) = 0
> close(12) = 0
> close(11) = 0
> unlink("/tmp/orbit-klausf/linc-1282-0-6094bc6991603") = 0
> close(14) = 0
> write(6, "@", 1) = 1
> close(6) = 0
> close(5) = 0
> rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER|SA_NOCLDSTOP, 0x7f65d6b3b8f0}, {0x7f65d40a3860, [], SA_RESTORER|SA_NOCLDSTOP, 0x7f65d6b3b8f0}, 8) = 0
> exit_group(0)


and following when an error occurs:
> writev(16, [{"<\10\2\0;\6\340\5F\6\5\0!\6\340\5\10\0\340\5\0\0\0\0U\0\33\0\232\7\2\0"..., 16380}, {NULL, 0}, {"", 0}], 3) = 16380
> read(16, 0xbc49d4, 4096) = -1 EAGAIN (Resource temporarily unavailable)
> poll([{fd=16, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=16, revents=POLLOUT}])
> writev(16, [{"\232\10\t\0\3\6\340\5R\6\340\5C\6\340\5=\6\340\5\0\0\0\0\0\0\0\0\2\0\2\0"..., 4256}, {NULL, 0}, {"", 0}], 3) = 4256
> poll([{fd=16, events=POLLIN}], 1, -1) = 1 ([{fd=16, revents=POLLIN}])
> read(16, "\16\0\317\26s\0\340\5\0\0>\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 64
> read(16, 0xbc49d4, 4096) = -1 EAGAIN (Resource temporarily unavailable)
> poll([{fd=7, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=7, revents=POLLOUT}])
> writev(7, [{"7\0\4\0\25\1\300\5\v\0\300\5\0\0\0\0007\1\4\0\26\1\300\5\v\0\300\5\0\0\0\0"..., 9940}, {NULL, 0}, {"", 0}], 3) = 9940
> read(7, 0xb44704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
> read(7, 0xb44704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
> read(7, 0xb44704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
> poll([{fd=3, events=POLLIN}, {fd=11, events=POLLIN|POLLPRI}, {fd=13, events=POLLIN|POLLPRI}, {fd=14, events=POLLIN|POLLPRI}, {fd=15, events=POLLIN|POLLPRI}, {fd=16, events=POLLIN}, {fd=17, events=POLLIN}, {fd=18, events=POLLIN}, {fd=19, events=POLLIN}, {fd=7, events=POLLIN}], 10, 0) = 0 (Timeout)
> read(7, 0xb44704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
> fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb00bc75000
> write(1, "last\n", 5last
> ) = 5
> rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fb0124088f0}, {0x4d9820, [], SA_RESTORER, 0x7fb0124088f0}, 8) = 0
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV +++
> Segmentation fault




thanks a lot for any ideas or explanations






From: Gelonida on
Jusy FYI:

I made further tests and can crash the python script even if I delete
the linesassigning strings to variables a to f

On 08/12/2010 01:07 AM, Gelonida wrote:
> Hi Guys,
> I'm desperate. I'm having a real application, which fails rather often
> when finishing it. I'm not sure, whether any serious problem could be
> hidden behind it
>
> The script is a pyqt script, which segfaults most of the time on my
> ubuntu 10.4 linux 64 bit and I'm having trouble to understand why.
>
> Trying to create the smallest possible test case I ended up with
> following script, which I named dodo.py and which i made executable with
> chmod +x ./dodo.py
>
> #!/usr/bin/env python
> from PyQt4.QtGui import
> QDialog,QGridLayout,QLabel,QComboBox,QPushButton,QApplication
> a = "one"
> b = "unused"
> c = "also unused"
> d= "ans also unused"
> e = "another var"
> f = "something"
> class MyForm(QDialog):
> def __init__(self,parent=None,config=None,ini_info=None):
> super(MyForm,self).__init__(parent=parent)
> grid = QGridLayout()
> quit_btn = QPushButton("Quit")
> quit_btn.clicked.connect(self.quit)
> grid.addWidget(quit_btn,0,0)
> name = "a_name"
> vals_box = QComboBox()
> vals_box.addItem("one")
> vals_box.addItem("two")
> grid.addWidget(vals_box,0,1)
> self.setLayout(grid)
> def quit(self):
> self.close()
> if __name__ == "__main__":
> app = QApplication([])
> myform = MyForm()
> myform.show()
> retcode = app.exec_()
> print "last"
>
>
>
> In order to perform the test several times I typed on the command line:
>
> a="" ; while [ "$a" = "" ] ; do ./dodo.py ; read -t 1 a ; done
>
> As soon as the window shows up
> I click twice (slowly ) on 'one' and then on quit.
>
> Sample output can be seen here:
> gelonida(a)mypc:/my/directory$ a="" ; while [ "$a" = "" ] ; do ./dodo.py ;
> read -t 1 a ; done
> last
> last
> Segmentation fault
> last
> last
> Segmentation fault
> last
> Segmentation fault
> last
> Segmentation fault
> last
> last
> last
> last
> last
> Segmentation fault
> last
> last
> Segmentation fault
> last
> Segmentation fault
>
>
> as you see the segfault happens rather often.
>
> Does anybody see something suspicious with my code?
> Can anybody else reproduce this?
> as soon as I remove more lines the error seems to disappear.
>
> What else could I do to debug this issue?
>
> thanks for help or other ideas
>
>
>
> If I run my script with strace ./dodo.py
> I get following last lines for a run without error
>> rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f65d6b3b8f0}, {0x4d9820, [], SA_RESTORER, 0x7f65d6b3b8f0}, 8) = 0
>> munmap(0x7f65c6344000, 622280) = 0
>> brk(0x2d71000) = 0x2d71000
>> poll([{fd=7, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=7, revents=POLLIN|POLLOUT}])
>> read(7, "\22\0\233\6\2\0\300\5\2\0\300\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 384
>> writev(7, [{"\232\7\2\0\210\0\300\0056\0\2\0\207\0\300\5<\0\2\0\211\0\300\5\232\7\2\0s\0\300\5"..., 540}, {NULL, 0}, {"", 0}], 3) = 540
>> poll([{fd=7, events=POLLIN}], 1, -1) = 1 ([{fd=7, revents=POLLIN}])
>> read(7, "\34\0\241\6r\0\300\5\234\1\0\0\377\261\220\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 1472
>> read(7, 0x29fa704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
>> poll([{fd=7, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=7, revents=POLLOUT}])
>> writev(7, [{"O\7\2\0\1\0\300\5<\0\2\0\0\0\300\5+\0\1\0", 20}, {NULL, 0}, {"", 0}], 3) = 20
>> poll([{fd=7, events=POLLIN}], 1, -1) = 1 ([{fd=7, revents=POLLIN}])
>> read(7, "\1\2\333\6\0\0\0\0\5\0\300\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096) = 32
>> read(7, 0x29fa704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
>> close(7) = 0
>> write(19, "\1\v\3\200\1\0\0\0\0\0\0\0\t\0\0\0", 16) = 16
>> close(19) = 0
>> open("/proc/stat", O_RDONLY|O_CLOEXEC) = 7
>> read(7, "cpu 59482 54 13580 7506040 4761"..., 8192) = 2439
>> close(7) = 0
>> writev(15, [{"GIOP\1\2\1\5\0\0\0\0", 12}], 1) = 12
>> close(15) = 0
>> writev(13, [{"GIOP\1\2\1\5\0\0\0\0", 12}], 1) = 12
>> close(13) = 0
>> close(12) = 0
>> close(11) = 0
>> unlink("/tmp/orbit-klausf/linc-1282-0-6094bc6991603") = 0
>> close(14) = 0
>> write(6, "@", 1) = 1
>> close(6) = 0
>> close(5) = 0
>> rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER|SA_NOCLDSTOP, 0x7f65d6b3b8f0}, {0x7f65d40a3860, [], SA_RESTORER|SA_NOCLDSTOP, 0x7f65d6b3b8f0}, 8) = 0
>> exit_group(0)
>
>
> and following when an error occurs:
>> writev(16, [{"<\10\2\0;\6\340\5F\6\5\0!\6\340\5\10\0\340\5\0\0\0\0U\0\33\0\232\7\2\0"..., 16380}, {NULL, 0}, {"", 0}], 3) = 16380
>> read(16, 0xbc49d4, 4096) = -1 EAGAIN (Resource temporarily unavailable)
>> poll([{fd=16, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=16, revents=POLLOUT}])
>> writev(16, [{"\232\10\t\0\3\6\340\5R\6\340\5C\6\340\5=\6\340\5\0\0\0\0\0\0\0\0\2\0\2\0"..., 4256}, {NULL, 0}, {"", 0}], 3) = 4256
>> poll([{fd=16, events=POLLIN}], 1, -1) = 1 ([{fd=16, revents=POLLIN}])
>> read(16, "\16\0\317\26s\0\340\5\0\0>\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 64
>> read(16, 0xbc49d4, 4096) = -1 EAGAIN (Resource temporarily unavailable)
>> poll([{fd=7, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=7, revents=POLLOUT}])
>> writev(7, [{"7\0\4\0\25\1\300\5\v\0\300\5\0\0\0\0007\1\4\0\26\1\300\5\v\0\300\5\0\0\0\0"..., 9940}, {NULL, 0}, {"", 0}], 3) = 9940
>> read(7, 0xb44704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
>> read(7, 0xb44704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
>> read(7, 0xb44704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
>> poll([{fd=3, events=POLLIN}, {fd=11, events=POLLIN|POLLPRI}, {fd=13, events=POLLIN|POLLPRI}, {fd=14, events=POLLIN|POLLPRI}, {fd=15, events=POLLIN|POLLPRI}, {fd=16, events=POLLIN}, {fd=17, events=POLLIN}, {fd=18, events=POLLIN}, {fd=19, events=POLLIN}, {fd=7, events=POLLIN}], 10, 0) = 0 (Timeout)
>> read(7, 0xb44704, 4096) = -1 EAGAIN (Resource temporarily unavailable)
>> fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
>> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb00bc75000
>> write(1, "last\n", 5last
>> ) = 5
>> rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fb0124088f0}, {0x4d9820, [], SA_RESTORER, 0x7fb0124088f0}, 8) = 0
>> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
>> +++ killed by SIGSEGV +++
>> Segmentation fault
>
>
>
>
> thanks a lot for any ideas or explanations
>
>
>
>
>
>


From: Lee Harr on

> I'm desperate. I'm having a real application, which fails rather often
> when finishing it. I'm not sure, whether any serious problem could be
> hidden behind it
>
> The script is a pyqt script, which segfaults most of the time on my
> ubuntu 10.4 linux 64 bit and I'm having trouble to understand why.


Looks to be a known issue:
http://www.google.com/search?q=pyqt+segfault+on+exit
https://launchpad.net/bugs/561303

The last activity on that bug is almost 2 months ago...
Hopefully the fix will be distributed soon.


From: Gelonida on
Lee,

On 08/13/2010 12:53 AM, Lee Harr wrote:
>
>> I'm desperate. I'm having a real application, which fails rather often
>> when finishing it. I'm not sure, whether any serious problem could be
>> hidden behind it
>>
>> The script is a pyqt script, which segfaults most of the time on my
>> ubuntu 10.4 linux 64 bit and I'm having trouble to understand why.
>
>
> Looks to be a known issue:
> http://www.google.com/search?q=pyqt+segfault+on+exit
> https://launchpad.net/bugs/561303
>
> The last activity on that bug is almost 2 months ago...
> Hopefully the fix will be distributed soon.



This seems to be the problem.


In my case I can workaround the issue by adding one line.

if __name__ == "__main__":
app = QApplication([])
myform = MyForm()
myform.show()
retcode = app.exec_()
myform = None # <<<< THIS IS THE WORK AROUND
print "last"


Thaks a lot


From: Gelonida on
On 08/13/2010 09:11 AM, Gelonida wrote:
> Lee,
>
> On 08/13/2010 12:53 AM, Lee Harr wrote:
>>
>>> I'm desperate. I'm having a real application, which fails rather often
>>> when finishing it. I'm not sure, whether any serious problem could be
>>> hidden behind it
>>>
>>> The script is a pyqt script, which segfaults most of the time on my
>>> ubuntu 10.4 linux 64 bit and I'm having trouble to understand why.
>>
>>
>> Looks to be a known issue:
>> http://www.google.com/search?q=pyqt+segfault+on+exit
>> https://launchpad.net/bugs/561303
>>
>> The last activity on that bug is almost 2 months ago...
>> Hopefully the fix will be distributed soon.
>
>
>
> This seems to be the problem.
>
>
> In my case I can workaround the issue by adding one line.
>
> if __name__ == "__main__":
> app = QApplication([])
> myform = MyForm()
> myform.show()
> retcode = app.exec_()
> myform = None # <<<< THIS IS THE WORK AROUND
> print "last"
>
For more complex multi widget examples it doesn't seem enough to just
destroy the main widget.
probably I had to recursively assign all widgets / dialogues sub widgets
to None.

So I'll just try to stay away from this pyqt release and stick with
older or newer ones.