[Qt-interest] SegFaults I cannot interpret

Pavel Koshevoy pavel at aragog.com
Tue Feb 24 19:11:40 CET 2009


Run your application under valgrind.  You may have dangling pointers or 
memory stomping issues, you need to use a memory debugger.  Try enabling 
glibc memory debugging facilities, or use electric fence.  If your code 
is multi-threaded make sure you are using thread safe classes and 
reentrant functions, everything else has to be protected against 
concurrent access by you, using QMutexLocker etc...

    Pavel

Andrea Franceschini wrote:
> Hello guys. Since I started developing this application I'm working
> on, I've had any sort of segfault, sometimes due to errors of mine --
> which have been fixed -- and sometimes due to conditions I cannot
> really grasp. I fear the problem may be somehow related to threading
> issues but it only appears sometimes while other times I can run
> flawlessly for a lot of time.
>
> Basically I have a QPainter derived class which has pointers to my
> datas and displays them on an appropriate QGLWidget. I tried to put
> mutexes everywhere (nontheless I tried with the QMutexLocker if by any
> chance I was missing something) but I found that it really affected
> the performance of the painter (while the logic still worked really
> well).
>
> Most of the sgefaults I have look like
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0xb6d8c710 (LWP 31154)]
> 0x0804c96a in QBasicAtomicInt::ref (this=0x0) at
> /usr/include/qt4/QtCore/qatomic_i386.h:115
> 115                      : "memory");
> (gdb) bt
> #0  0x0804c96a in QBasicAtomicInt::ref (this=0x0) at
> /usr/include/qt4/QtCore/qatomic_i386.h:115
> #1  0x0804d133 in QList (this=0xbffbd520, l=@0x866fec8) at
> /usr/include/qt4/QtCore/qlist.h:106
> #2  0x080513af in Doodle::Painter::paint (this=0x81cff10,
> painter=0xbffbd63c, event=0xbffbdaf4) at Painter.cpp:95
> ...
>
> or
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0xb6e86710 (LWP 30961)]
> 0x0804c99e in QListData::size (this=0xa2b54a8) at
> /usr/include/qt4/QtCore/qlist.h:82
> 82          inline int size() const { return d->end - d->begin; }
> (gdb) bt
> #0  0x0804c99e in QListData::size (this=0xa2b54a8) at
> /usr/include/qt4/QtCore/qlist.h:82
> #1  0x0804ee01 in QList<QList<Doodle::Cursor> >::size (this=0xa2b54a8)
> at /usr/include/qt4/QtCore/qlist.h:112
> #2  0x08051219 in Doodle::Painter::paint (this=0x9e80f10,
> painter=0xbf8b972c, event=0xbf8b9be4) at Painter.cpp:96
> ...
>
> (despite of the line number, the instruction was the same and I
> double-makeittriple-checked: it shouldn't return null pointers or any
> other kind of bad stuff).
>
> Clearly these are something that go far beyond my ability of
> inspection (and patience, since I'm working on strict time constraint
> and a single step-debug session would take an entire day and even
> wouldn't give any warranty of producing the crash at all) so if
> anybody of you guys can give me some insight, I'm totally lost.
>
> Thanks
>   




More information about the Qt-interest-old mailing list