translate() calls in QtSql

Nick Shaforostoff shafff at ukr.net
Mon May 18 16:53:18 BST 2009


On Понедельник 18 мая 2009 08:19:08 Thiago Macieira wrote:
> Nick Shaforostoff wrote:
> >My user was hit by this crash:
> > https://bugs.kde.org/show_bug.cgi?id=193063
> >
> >Apparently, it is caused by calling QCoreApplication::translate from
> > QSQLiteResultPrivate::fetchNext (running in background thread in my
> > app):
> > http://cep.xor.aps.anl.gov/software/qt4-x11-4.2.2-browser/d8/d09/qsql__
> >sqlite_8cpp-source.html
> >
> >Note that the error text is set immediately, and not when it is
> > requested by a programmer. (i.e. by calling QSqlQuery::lastError ()).
> >(so that he at least could protect such calls with mutexes)
> >
> >It is common to run queries in background thread, so any program that
> > does this is prone to crashes.
> >
> >So one solution that came to my mind is switching to lazy setting of
> > error texts: the driver sets error code, and when the error text is
> > requested, the text is looked up in special table.
> >
> >What do you think?
> >Should I file the bug report to Qt?
> 
> No.
> 
> I don't understand the error (and bugzilla won't load).
Thread 2 (Thread 0x7fcbb44f6950 (LWP 14581)):
#0  __lll_lock_wait_private () at
../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:91
#1  0x00007fcbbbb025ae in _L_lock_3848 () from /lib/libc.so.6
#2  0x00007fcbbbafec4b in *__GI___libc_free (mem=0x7fcbbbdd9a00) at
malloc.c:3623
#3  0x00007fcbbc3dea32 in QByteArray::operator= (this=0x7a2528, other=@0x80) at
tools/qbytearray.cpp:851
#4  0x00007fcbbd7f0484 in KCatalogPrivate::setupGettextEnv (this=0x7a2510) at
../../kdecore/localization/kcatalog.cpp:166
#5  0x00007fcbbd7f06fd in KCatalog::translateStrict (this=0x80,
msgctxt=0x952c20 "��������1", msgid=0xffffffffffffffff <Address
0xffffffffffffffff out of bounds>)
    at ../../kdecore/localization/kcatalog.cpp:242
#6  0x00007fcbbd803df7 in KLocalePrivate::translate_priv (this=0x7a2280,
msgctxt=0x7fcbb3ae083d "QSQLiteResult", msgid=0x7fcbb3ae0854 "Unable to fetch
row", msgid_plural=0x0, n=0, 
    language=0x7fcbb44f5710, translation=0x7fcbb44f5720) at
../../kdecore/localization/klocale.cpp:762
#7  0x00007fcbbd804925 in KLocale::translateQt (this=0x78e000,
context=0x7fcbb3ae083d "QSQLiteResult", sourceText=0x7fcbb3ae0854 "Unable to
fetch row", comment=0x0)
    at ../../kdecore/localization/klocale.cpp:850
#8  0x00007fcbbe3ac50d in KDETranslator::translate (this=<value optimized out>,
context=0x7fcbb3ae083d "QSQLiteResult", sourceText=0x7fcbb3ae0854 "Unable to
fetch row", message=0x0)
    at ../../kdeui/kernel/kapplication.cpp:462
#9  0x00007fcbbc4e1cf9 in QTranslator::translate (this=0x80, context=0x952c20
"��������1", sourceText=0xffffffffffffffff <Address 0xffffffffffffffff out of
bounds>, disambiguation=0x952c30 "", n=0)
    at kernel/qtranslator.cpp:801
#10 0x00007fcbbc4c8699 in QCoreApplication::translate (context=0x7fcbb3ae083d
"QSQLiteResult", sourceText=0x7fcbb3ae0854 "Unable to fetch row",
disambiguation=0x0, 
    encoding=QCoreApplication::CodecForTr, n=-1) at
kernel/qcoreapplication.cpp:1641
#11 0x00007fcbbc4c8a7f in QCoreApplication::translate (context=0x80 <Address
0x80 out of bounds>, sourceText=0x952c20 "��������1", 
    disambiguation=0xffffffffffffffff <Address 0xffffffffffffffff out of
bounds>, encoding=9776176) at kernel/qcoreapplication.cpp:1556
#12 0x00007fcbb3aded31 in QSQLiteResultPrivate::fetchNext (this=0x7fcbac4eaf50,
values=@0x7fcbac527c40, idx=<value optimized out>, initialFetch=<value
optimized out>)
    at ../../../sql/drivers/sqlite/qsql_sqlite.cpp:264
#13 0x00007fcbb3adf86e in QSQLiteResult::exec (this=0x7fcbac0b1db0) at
../../../sql/drivers/sqlite/qsql_sqlite.cpp:402
#14 0x00007fcbbdd42337 in QSqlQuery::exec (this=0x7fcbb44f5db0) at
kernel/qsqlquery.cpp:935
#15 0x000000000047b7fa in getConfig (db=<value optimized out>,
markup=@0x7fcbb44f5f40, accel=@0x7fcbb44f5f30) at
../../../lokalize/src/tm/jobs.cpp:682
#16 0x000000000047ec84 in TM::SelectJob::run (this=0xbb05b0) at
../../../lokalize/src/tm/jobs.cpp:1105
#17 0x00007fcbbdf7c83c in ThreadWeaver::JobRunHelper::runTheJob
(this=0x7fcbb44f5ff0, th=0x7d1c20, job=0xbb05b0) at
../../../threadweaver/Weaver/Job.cpp:106
#18 0x00007fcbbdf7cb61 in ThreadWeaver::Job::execute (this=0xbb05b0,
th=0x7d1c20) at ../../../threadweaver/Weaver/Job.cpp:135
#19 0x00007fcbbdf7baff in ThreadWeaver::ThreadRunHelper::run
(this=0x7fcbb44f6080, parent=0x7d0f60, th=0x7d1c20) at
../../../threadweaver/Weaver/Thread.cpp:95
#20 0x00007fcbbdf7bf89 in ThreadWeaver::Thread::run (this=0x7d1c20) at
../../../threadweaver/Weaver/Thread.cpp:142
#21 0x00007fcbbc3dc742 in QThreadPrivate::start (arg=0x7d1c20) at
thread/qthread_unix.cpp:189
#22 0x00007fcbb8326faa in start_thread (arg=<value optimized out>) at
pthread_create.c:300
#23 0x00007fcbbbb5929d in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#24 0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7fcbbf668760 (LWP 14580)):
[KCrash Handler]
#5  _int_malloc (av=0x7fcbbbdd9a00, bytes=33) at malloc.c:4171
#6  0x00007fcbbbb00e54 in _int_realloc (av=<value optimized out>,
oldmem=0xe447d0, bytes=<value optimized out>) at malloc.c:5035
#7  0x00007fcbbbb01dbf in *__GI___libc_realloc (oldmem=0xe447d0, bytes=40) at
malloc.c:3708
#8  0x00007fcbbc3fff7b in QListData::realloc (this=0x7fffc779c890, alloc=<value
optimized out>) at tools/qlistdata.cpp:111
#9  0x00007fcbbc40019b in QListData::append (this=0x7fffc779c890) at
tools/qlistdata.cpp:131
#10 0x00007fcbbd711004 in QList<QString>::append (this=0x7fffc779c890, t=@0x21)
at /usr/include/qt4/QtCore/qlist.h:421
#11 0x00007fcbbd80b775 in KLocalizedStringPrivate::substituteSimple
(this=0x975df0, trans=@0x7fffc779caf0, plchar=@0x7fffc779cbd0, partial=<value
optimized out>)
    at ../../kdecore/localization/klocalizedstring.cpp:398
#12 0x00007fcbbd80f7d9 in KLocalizedStringPrivate::toString (this=0x975df0,
locale=0x78e000) at ../../kdecore/localization/klocalizedstring.cpp:294
#13 0x00007fcbbd810507 in KLocalizedString::toString (this=0x7fffc779cce0) at
../../kdecore/localization/klocalizedstring.cpp:205
#14 0x0000000000458a74 in MsgCtxtView::process (this=0x99dcc0) at
/usr/include/klocalizedstring.h:735
#15 0x0000000000459448 in MsgCtxtView::qt_metacall (this=0x99dcc0,
_c=QMetaObject::InvokeMetaMethod, _id=4, _a=0x7fffc779d050) at
./msgctxtview.moc:75
#16 0x00007fcbbc4da862 in QMetaObject::activate (sender=0xc9d6c0,
from_signal_index=<value optimized out>, to_signal_index=4, argv=0x20) at
kernel/qobject.cpp:3120
#17 0x00007fcbbc4dfb9f in QSingleShotTimer::timerEvent (this=0xc9d6c0) at
kernel/qtimer.cpp:298
#18 0x00007fcbbc4d4b43 in QObject::event (this=0xc9d6c0, e=0x21) at
kernel/qobject.cpp:1082
#19 0x00007fcbbc9934fd in QApplicationPrivate::notify_helper (this=0x6ed2c0,
receiver=0xc9d6c0, e=0x7fffc779d710) at kernel/qapplication.cpp:4057
#20 0x00007fcbbc99b77a in QApplication::notify (this=0x7fffc779da50,
receiver=0xc9d6c0, e=0x7fffc779d710) at kernel/qapplication.cpp:4022
#21 0x00007fcbbe3a755b in KApplication::notify (this=0x7fffc779da50,
receiver=0xc9d6c0, event=0x7fffc779d710) at
../../kdeui/kernel/kapplication.cpp:307
#22 0x00007fcbbc4c4e4c in QCoreApplication::notifyInternal
(this=0x7fffc779da50, receiver=0xc9d6c0, event=0x7fffc779d710) at
kernel/qcoreapplication.cpp:610
#23 0x00007fcbbc4f2036 in QTimerInfoList::activateTimers (this=0x6f0ea0) at
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:213
#24 0x00007fcbbc4ee55d in timerSourceDispatch (source=<value optimized out>) at
kernel/qeventdispatcher_glib.cpp:164
#25 0x00007fcbb8574f7a in g_main_context_dispatch () from
/usr/lib/libglib-2.0.so.0
#26 0x00007fcbb8578640 in ?? () from /usr/lib/libglib-2.0.so.0
#27 0x00007fcbb85787dc in g_main_context_iteration () from
/usr/lib/libglib-2.0.so.0
#28 0x00007fcbbc4ee4bf in QEventDispatcherGlib::processEvents (this=0x6d9890,
flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:324
#29 0x00007fcbbca2bc7f in QGuiEventDispatcherGlib::processEvents
(this=0x7fcbbbdd9a00, flags=<value optimized out>) at
kernel/qguieventdispatcher_glib.cpp:202
#30 0x00007fcbbc4c36f2 in QEventLoop::processEvents (this=<value optimized
out>, flags={i = -948315776}) at kernel/qeventloop.cpp:149
#31 0x00007fcbbc4c3abd in QEventLoop::exec (this=0x7fffc779d9c0, flags={i =
-948315696}) at kernel/qeventloop.cpp:200
#32 0x00007fcbbc4c5d84 in QCoreApplication::exec () at
kernel/qcoreapplication.cpp:888
#33 0x000000000042ca7d in main (argc=5, argv=0x7fffc779df08) at
../../../lokalize/src/main.cpp:111
Current language:  auto; currently asm
#0  0x00007fcbbbb29831 in nanosleep () from /lib/libc.so.6
Current language:  auto; currently c

> What's wrong? What's the error?
As you can see, both threads are calling locale-related functions.

> The QCoreApplication::translate() function is explicitly marked as being 
> reentrant (http://doc.trolltech.com/4.5/qcoreapplication.html#translate, 
> http://doc.trolltech.com/4.5/threads.html#reentrant), which means it's 
> safe to call translate() without a mutex.
only if the data is different. If I'm not mistaken, there is no separate message catalogs for each thread.





More information about the kde-core-devel mailing list