translate() calls in QtSql

Albert Astals Cid aacid at kde.org
Mon May 18 20:06:28 BST 2009


A Dilluns, 18 de maig de 2009, Nick Shaforostoff va escriure:
> 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

>
> 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

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

KDE functions that hook on Qt ones. Have you tried using kdelibs from trunk?

Here the attached program crashes on 4.2.3 but not on trunk. I think Chusslove 
added some locking to kdelibs maybe he forgot to backport.

Albert

>
> > 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 744 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090518/94b0d39b/attachment.cpp>


More information about the kde-core-devel mailing list