[Qt-interest] Segfault with a qapplication running in a boost::thread

Damien R damien.rg+news at gmail.com
Tue Oct 27 16:56:40 CET 2009


Hi,
I have to create a qt application, but I do not have the source code
of the software.
I can extend the software by creating a shared library which will be
loaded by the software.
I am sure the software does not have an another gui thread.

Although the doc of Qt say:
"Note that QCoreApplication::exec() must always be called from the
main thread (the thread that executes main()), not from a QThread. In
GUI applications, the main thread is also called the GUI thread
because it's the only thread that is allowed to perform GUI-related
operations.",
I think it is correct to created a boost::thread which creates an
instance of QApplication, and call exec().
It works with simple app, but I have weird behavior with an
application  which show images from a camera.

The app crashes after about 1h with the current backtrace :
#0  0xb7f35430 in __kernel_vsyscall ()
#1  0xb7bd16d0 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7bd3098 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0xb7c0f24d in ?? () from /lib/tls/i686/cmov/libc.so.6
#4  0xb7c15604 in ?? () from /lib/tls/i686/cmov/libc.so.6
#5  0xb7c185b6 in ?? () from /lib/tls/i686/cmov/libc.so.6
#6  0xb7c18fbf in ?? () from /lib/tls/i686/cmov/libc.so.6
#7  0xb7c19ee6 in realloc () from /lib/tls/i686/cmov/libc.so.6
#8  0xb6f8c064 in qRealloc (ptr=0xa235e98, size=32) at global/qmalloc.cpp:65
#9  0xb6fb6d25 in QListData::realloc (this=0xb5af0074, alloc=3) at
tools/qlistdata.cpp:111
...
#36 0xb708406a in QEventLoop::processEvents (this=0xb5af1290, flags={i
= -1246817704}) at kernel/qeventloop.cpp:149
#37 0xb70844aa in QEventLoop::exec (this=0xb5af1290, flags={i =
-1246817640}) at kernel/qeventloop.cpp:200

I am suspicious about the stackframe #37 when the backtrace shows
flags={i = -1246817640}.
So, is it a dangling pointer which corrupt the flags, or something else ?

The complete stack for those interested :
#0  0xb7f35430 in __kernel_vsyscall ()
No symbol table info available.
#1  0xb7bd16d0 in raise () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#2  0xb7bd3098 in abort () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#3  0xb7c0f24d in ?? () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#4  0xb7c15604 in ?? () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#5  0xb7c185b6 in ?? () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#6  0xb7c18fbf in ?? () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#7  0xb7c19ee6 in realloc () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#8  0xb6f8c064 in qRealloc (ptr=0xa235e98, size=32) at global/qmalloc.cpp:65
No locals.
#9  0xb6fb6d25 in QListData::realloc (this=0xb5af0074, alloc=3) at
tools/qlistdata.cpp:111
x = <value optimized out>
#10 0xb6fb6f93 in QListData::append (this=0xb5af0074) at tools/qlistdata.cpp:131
n = <value optimized out>
#11 0xb73fdc3b in QPainterPath::toSubpathPolygons (this=0xb5af02a8,
matrix=@0xb5af009c)
   at ../../include/QtCore/../../src/corelib/tools/qlist.h:426
i = 170090156
flatCurves = {{p = {static shared_null = {ref = {_q_value = 1291},
alloc = 0, begin = 0, end = 0,
       sharable = 1, array = {0x0}}, d = 0xb5af0074}, d = 0xb5af0074}}
current = {<QVector<QPointF>> = {{p = 0xa26acc8, d = 0xa26acc8}}, <No
data fields>}
#12 0xb73fe353 in QPainterPath::toFillPolygon (this=0xb5af02a8,
matrix=@0xb5af009c) at painting/qpainterpath.cpp:2634
polygon = {<QVector<QPointF>> = {{p = 0xb5af02a4, d = 0xb5af02a4}},
<No data fields>}
flats = {{p = {static shared_null = {ref = {_q_value = 1291}, alloc =
0, begin = 0, end = 0, sharable = 1,
       array = {0x0}}, d = 0xa235e98}, d = 0xa235e98}}
#13 0xb73fe832 in QPainterPath::toFillPolygon (this=0xb5af02a8,
matrix=@0xb5af0210) at painting/qpainterpath.cpp:2654
No locals.
#14 0xb74c9c28 in QX11PaintEngine::updateState (this=0xa2433d0,
state=@0xa21f1a4)
   at painting/qpaintengine_x11.cpp:1066
clip_poly_dev = {<QVector<QPointF>> = {{p = 0xb7d06170, d =
0xb7d06170}}, <No data fields>}
clipped_poly_dev = {<QVector<QPointF>> = {{p = 0x1, d = 0x1}}, <No data fields>}
d = (QX11PaintEnginePrivate * const) 0xa1f6180
---Type <return> to continue, or q <return> to quit---
#15 0xb73e74c8 in QPainterPrivate::updateStateImpl (this=0xa26b208,
newState=0xa21f1a0) at painting/qpainter.cpp:899
No locals.
#16 0xb73e75ab in QPainterPrivate::updateState (this=0xa26b208,
newState=0xa21f1a0) at painting/qpainter.cpp:927
No locals.
#17 0xb73eda71 in QPainter::setClipRegion (this=0xb5af07e8,
r=@0xb5af069c, op=Qt::ReplaceClip)
   at painting/qpainter.cpp:2662
d = (QPainterPrivate * const) 0xa26b208
#18 0xb731bc0a in QWidgetPrivate::paintBackground (this=0xa088640,
painter=0xb5af07e8, rgn=@0xb5af07f4,
   offset=@0xb5af07dc, flags=<value optimized out>) at kernel/qwidget.cpp:2070
opt = {version = 0, type = 0, state = {i = 0}, direction =
Qt::LeftToRight, rect = {x1 = 0, y1 = 1072693248,
   x2 = 0, y2 = 170394608}, fontMetrics = {d = 0xb7b5fff4}, palette =
{static staticMetaObject = {d = {
       superdata = 0x0, stringdata = 0xb79ce6c0 "QPalette", data =
0xb79ce800, extradata = 0x0}}, d = 0xaf,
   current_group = 5, resolve_mask = 268435455}}
q = (const QWidget * const) 0x9abc410
autoFillBrush = {d = 0xa210070}
#19 0xb731c954 in QWidgetPrivate::drawWidget (this=0xa088640,
pdev=0xa23a7b4, rgn=@0xb5af0884, offset=@0xb5af087c,
   flags=4, sharedPainter=0x0, backingStore=0xa2393f0) at
kernel/qwidget.cpp:5024
p = {static staticMetaObject = {d = {superdata = 0x0, stringdata =
0xb79cf520 "QPainter", data = 0xb79cf5c0,
     extradata = 0x0}}, d_ptr = 0xa26b208}
scrollAreaOffset = {xp = 0, yp = 0}
scrollArea = <value optimized out>
paintEngine = (class QPaintEngine *) 0xa2433d0
e = {<QEvent> = {_vptr.QEvent = 0xb7d06140, d = 0xb7c16c74, t = 28660,
posted = 0, spont = 1, m_accept = 0,
   reserved = 5884}, m_rect = {x1 = 44, y1 = -1246820220, x2 =
-1246820504, y2 = -1210081465}, m_region = {
   d = 0x2c, static shared_empty = {ref = {_q_value = 206}, rgn = 0x0,
xrectangles = 0x0, qt_rgn = 0x0}},
 m_erased = 132}
onScreen = false
asRoot = false
toBePainted = {d = 0xa234d60, static shared_empty = {ref = {_q_value =
206}, rgn = 0x0, xrectangles = 0x0,
   qt_rgn = 0x0}}
#20 0xb731cebe in QWidgetPrivate::paintSiblingsRecursive
(this=0x9ab0a98, pdev=0xa23a7b4, siblings=@0x9ab0aa4,
   index=0, rgn=@0xb5af0b38, offset=@0xa239414, flags=4,
sharedPainter=0x0, backingStore=0xa2393f0)
   at kernel/qwidget.cpp:5156
wRegion = {d = 0xa234d60, static shared_empty = {ref = {_q_value =
206}, rgn = 0x0, xrectangles = 0x0,
   qt_rgn = 0x0}}
boundingRect = {x1 = 20, y1 = 184, x2 = 1519, y2 = 1029}
dirtyBoundingRect = <value optimized out>
wd = (QWidgetPrivate *) 0xa088640
hasMask = false
#21 0xb731c30a in QWidgetPrivate::drawWidget (this=0x9ab0a98,
pdev=0xa23a7b4, rgn=@0xb5af0b38, offset=@0xa239414,
   flags=4, sharedPainter=0x0, backingStore=0xa2393f0) at
kernel/qwidget.cpp:5095
asRoot = true
toBePainted = {d = 0xa23a748, static shared_empty = {ref = {_q_value =
206}, rgn = 0x0, xrectangles = 0x0,
   qt_rgn = 0x0}}
#22 0xb74d908a in QWidgetBackingStore::sync (this=0xa2393f0) at
painting/qbackingstore.cpp:1266
tlwExtra = <value optimized out>
updatesDisabled = false
tlwRect = {x1 = 0, y1 = 0, x2 = 1679, y2 = 1049}
surfaceGeometry = {x1 = 0, y1 = 0, x2 = 1679, y2 = 1049}
repaintAllWidgets = false
toClean = {d = 0xa210428, static shared_empty = {ref = {_q_value =
206}, rgn = 0x0, xrectangles = 0x0,
   qt_rgn = 0x0}}
opaqueNonOverlappedWidgets = {a = 32, s = 0, ptr = 0xb5af0b6c, {
   array = "�\217\027��ʶ�\000\000\000\000\230\v���H\t��\030�\t\000\000\000\000\v\000\000\000�UЬ\f\000\000\000�UЬH\f���c\t��\030�\t(\f��\000\000\000\000�o��\f\000\000\000hA�\t�\v���\217\027�\020ī\tX{#\n�\v���Y\b�\020ī\tX{#\n\000\000\000\000����\020ī\t����\030\f��Ȩ.�\020ī\t",
q_for_alignment_1 = -5352868006230257676,
   q_for_alignment_2 = -6.0919292885808865e-50}}
beginPaintInfo = {wasFlushed = 0, nothingToPaint = 0,
windowSurfaceRecreated = 0}
dirtyCopy = {d = 0xa23a748, static shared_empty = {ref = {_q_value =
206}, rgn = 0x0, xrectangles = 0x0,
   qt_rgn = 0x0}}
#23 0xb730cbb6 in QWidgetPrivate::syncBackingStore (this=0x9ab0a98) at
kernel/qwidget.cpp:1603
bs = (QWidgetBackingStore *) 0x0
#24 0xb7314d85 in QWidget::event (this=0x9ab0a58, event=0xa269540) at
kernel/qwidget.cpp:7794
No locals.
#25 0xb72bde9c in QApplicationPrivate::notify_helper (this=0x9a4c650,
receiver=0x9ab0a58, e=0xa269540)
   at kernel/qapplication.cpp:4084
consumed = <value optimized out>
#26 0xb72c6282 in QApplication::notify (this=0xb5af133c,
receiver=0x9ab0a58, e=0xa269540)
   at kernel/qapplication.cpp:4049
res = true
#27 0xb7085a3b in QCoreApplication::notifyInternal (this=0xb5af133c,
receiver=0x9ab0a58, event=0xa269540)
   at kernel/qcoreapplication.cpp:602
result = false
cbdata = {0x9ab0a58, 0xa269540, 0xb5af0feb}
threadData = (QThreadData *) 0x9a56528
returnValue = <value optimized out>
#28 0xb7086695 in QCoreApplicationPrivate::sendPostedEvents
(receiver=0x0, event_type=0, data=0x9a56528)
   at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:213
e = (class QEvent *) 0xa269540
r = (class QObject *) 0x9ab0a58
locker = {{mtx = 0x9a56550, val = 161834320}}
startOffset = 0
i = (int &) @0x9a56548: 9
#29 0xb708688d in QCoreApplication::sendPostedEvents (receiver=0x0,
event_type=0) at kernel/qcoreapplication.cpp:1132
data = <value optimized out>
#30 0xb70b17ef in postEventSourceDispatch (s=0x9a66788)
   at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:218
No locals.
#31 0xb6d92b88 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#32 0xb6d960eb in ?? () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#33 0xb6d96268 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#34 0xb70b1438 in QEventDispatcherGlib::processEvents (this=0x9a645b0,
flags={i = -1246817816})
   at kernel/qeventdispatcher_glib.cpp:323
d = (QEventDispatcherGlibPrivate * const) 0x1
canWait = true
result = <value optimized out>
#35 0xb735f365 in QGuiEventDispatcherGlib::processEvents
(this=0x9a645b0, flags={i = -1246817768})
   at kernel/qguieventdispatcher_glib.cpp:202
d = (QGuiEventDispatcherGlibPrivate * const) 0x9a648e8
returnValue = false
#36 0xb708406a in QEventLoop::processEvents (this=0xb5af1290, flags={i
= -1246817704}) at kernel/qeventloop.cpp:149
d = (QEventLoopPrivate * const) 0x9aad688
#37 0xb70844aa in QEventLoop::exec (this=0xb5af1290, flags={i =
-1246817640}) at kernel/qeventloop.cpp:200
d = (QEventLoopPrivate * const) 0x9aad688
#38 0xb7086959 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:880
threadData = (QThreadData *) 0x9a56528
eventLoop = {<QObject> = {_vptr.QObject = 0xb71787a8, static
staticMetaObject = {d = {superdata = 0x0,
       stringdata = 0xb7120bc0 "QObject", data = 0xb7120c60, extradata
= 0xb71741b8}}, d_ptr = 0x9aad688,
   static staticQtMetaObject = {d = {superdata = 0x0, stringdata =
0xb712a3a0 "Qt", data = 0xb712d280,
       extradata = 0x0}}}, static staticMetaObject = {d = {superdata =
0xb71741a8,
     stringdata = 0xb7132040 "QEventLoop", data = 0xb7132060, extradata = 0x0}}}
returnCode = -1
#39 0xb72bdd17 in QApplication::exec () at kernel/qapplication.cpp:3553
No locals.
#40 0xb7f28bc7 in viewer::QtViewer::start_ () from
/usr/local/lib/aroccam/libraries/libaroccam_lib_qtviewer.so
No locals.
#41 0xb7f28f27 in boost::detail::thread_data<boost::_bi::bind_t<void,
boost::_mfi::mf0<void, viewer::QtViewer>,
boost::_bi::list1<boost::_bi::value<viewer::QtViewer*> > > >::run ()
  from /usr/local/lib/aroccam/libraries/libaroccam_lib_qtviewer.so
No locals.
#42 0xb7ebf848 in thread_proxy () from /usr/lib/libboost_thread-mt.so.1.37.0
No symbol table info available.
#43 0xb7b934ff in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
No symbol table info available.
#44 0xb7c8a49e in clone () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.

Thanks,

--
Damien R.




More information about the Qt-interest-old mailing list