Bug 218246 - Crash when trying to replace selected text with clipboard content [QVector<int>::at, QTextEngine::formatIndex, QTextEngine::format]
Summary: Crash when trying to replace selected text with clipboard content [QVector<in...
Status: RESOLVED FIXED
Alias: None
Product: lokalize
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Nick Shaforostoff
URL:
Keywords:
: 203180 204778 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-12-11 10:04 UTC by Anne-Marie Mahfouf
Modified: 2009-12-20 14:25 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fix for the crash (617 bytes, patch)
2009-12-19 15:48 UTC, stefan.asserhall
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anne-Marie Mahfouf 2009-12-11 10:04:24 UTC
Application: lokalize (1.0)
KDE Platform Version: 4.3.81 (KDE 4.3.81 (KDE 4.4 >= 20091204)) (Compiled from sources)
Qt Version: 4.6.0
Operating System: Linux 2.6.27-desktop-0.rc8.2mnb i686
Distribution: "Mandriva Linux 2009.0"

-- Information about the crash:
Difficult to say why it exactly crashed but it did it twice, maybe it has to do with <b> marking in selected text, not sure.

The crash can be reproduced everytime.

 -- Backtrace:
Application: Lokalize (lokalize), signal: Aborted
[Current thread is 1 (Thread 0xb567cb80 (LWP 8146))]

Thread 3 (Thread 0xb26beb90 (LWP 8147)):
#0  0xffffe424 in __kernel_vsyscall ()
#1  0xb609ec45 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/i686/libpthread.so.0
#2  0xb6124bf8 in QWaitConditionPrivate::wait (this=0x8b25380, time=4294967295) at thread/qwaitcondition_unix.cpp:87
#3  0xb61246f7 in QWaitCondition::wait (this=0x8b252c0, mutex=0x8b25078, time=4294967295) at thread/qwaitcondition_unix.cpp:159
#4  0xb78339ca in ThreadWeaver::WeaverImpl::blockThreadUntilJobsAreBeingAssigned (this=0x8b252a8, th=0x8da73a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WeaverImpl.cpp:365
#5  0xb783871a in ThreadWeaver::WorkingHardState::waitForAvailableJob (this=0x8b24fd0, th=0x8da73a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WorkingHardState.cpp:80
#6  0xb7833019 in ThreadWeaver::WeaverImpl::waitForAvailableJob (this=0x8b252a8, th=0x8da73a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WeaverImpl.cpp:356
#7  0xb7838837 in ThreadWeaver::WorkingHardState::applyForWork (this=0x8b24fd0, th=0x8da73a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WorkingHardState.cpp:71
#8  0xb7833c38 in ThreadWeaver::WeaverImpl::applyForWork (this=0x8b252a8, th=0x8da73a0, previous=0xa439c80) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WeaverImpl.cpp:351
#9  0xb78367b1 in ThreadWeaver::ThreadRunHelper::run (this=0xb26be344, parent=0x8b252a8, th=0x8da73a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/Thread.cpp:87
#10 0xb783698b in ThreadWeaver::Thread::run (this=0x8da73a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/Thread.cpp:142
#11 0xb6124156 in QThreadPrivate::start (arg=0x8da73a0) at thread/qthread_unix.cpp:244
#12 0xb609b315 in start_thread () from /lib/i686/libpthread.so.0
#13 0xb5ef925e in clone () from /lib/i686/libc.so.6

Thread 2 (Thread 0xb1e3ab90 (LWP 8150)):
#0  0xffffe424 in __kernel_vsyscall ()
#1  0xb609ec45 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/i686/libpthread.so.0
#2  0xb6124bf8 in QWaitConditionPrivate::wait (this=0x8b27cf0, time=4294967295) at thread/qwaitcondition_unix.cpp:87
#3  0xb61246f7 in QWaitCondition::wait (this=0x8b27c38, mutex=0x8ad4528, time=4294967295) at thread/qwaitcondition_unix.cpp:159
#4  0xb78339ca in ThreadWeaver::WeaverImpl::blockThreadUntilJobsAreBeingAssigned (this=0x8b27c20, th=0x97950a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WeaverImpl.cpp:365
#5  0xb783871a in ThreadWeaver::WorkingHardState::waitForAvailableJob (this=0x8ab3618, th=0x97950a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WorkingHardState.cpp:80
#6  0xb7833019 in ThreadWeaver::WeaverImpl::waitForAvailableJob (this=0x8b27c20, th=0x97950a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WeaverImpl.cpp:356
#7  0xb7838837 in ThreadWeaver::WorkingHardState::applyForWork (this=0x8ab3618, th=0x97950a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WorkingHardState.cpp:71
#8  0xb7833c38 in ThreadWeaver::WeaverImpl::applyForWork (this=0x8b27c20, th=0x97950a0, previous=0x9fa6b68) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/WeaverImpl.cpp:351
#9  0xb78367b1 in ThreadWeaver::ThreadRunHelper::run (this=0xb1e3a344, parent=0x8b27c20, th=0x97950a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/Thread.cpp:87
#10 0xb783698b in ThreadWeaver::Thread::run (this=0x97950a0) at /usr/local/trunk-src/kdelibs/threadweaver/Weaver/Thread.cpp:142
#11 0xb6124156 in QThreadPrivate::start (arg=0x97950a0) at thread/qthread_unix.cpp:244
#12 0xb609b315 in start_thread () from /lib/i686/libpthread.so.0
#13 0xb5ef925e in clone () from /lib/i686/libc.so.6

Thread 1 (Thread 0xb567cb80 (LWP 8146)):
[KCrash Handler]
#6  0xffffe424 in __kernel_vsyscall ()
#7  0xb5e46c00 in raise () from /lib/i686/libc.so.6
#8  0xb5e48668 in abort () from /lib/i686/libc.so.6
#9  0xb6117a2e in qt_message_output (msgType=QtFatalMsg, 
    buf=0x9df2a18 "ASSERT failure in QVector<T>::at: \"index out of range\", file ../../include/QtCore/../../src/corelib/tools/qvector.h, line 338") at global/qglobal.cpp:2226
#10 0xb6117c38 in qt_message (msgType=QtFatalMsg, msg=0xb62d35a4 "ASSERT failure in %s: \"%s\", file %s, line %d", ap=0xbfe9a404 "\026¿Ø¶\003¿Ø¶Ì¾Ø¶R\001") at global/qglobal.cpp:2272
#11 0xb6117ca6 in qFatal (msg=0xb62d35a4 "ASSERT failure in %s: \"%s\", file %s, line %d") at global/qglobal.cpp:2455
#12 0xb6117ce4 in qt_assert_x (where=0xb6d8bf16 "QVector<T>::at", what=0xb6d8bf03 "index out of range", file=0xb6d8becc "../../include/QtCore/../../src/corelib/tools/qvector.h", line=338)
    at global/qglobal.cpp:1997
#13 0xb65400f5 in QVector<int>::at (this=0x9942d10, i=2) at ../../include/QtCore/../../src/corelib/tools/qvector.h:338
#14 0xb67f8802 in QTextEngine::formatIndex (this=0xa074f28, si=0xa435440) at text/qtextengine.cpp:2153
#15 0xb67f8961 in QTextEngine::format (this=0xa074f28, si=0xa435440) at text/qtextengine.cpp:2175
#16 0xb67f9560 in QTextEngine::fontEngine (this=0xa074f28, si=@0xa435440, ascent=0xa435450, descent=0xa43544c, leading=0xa435454) at text/qtextengine.cpp:1751
#17 0xb67fade2 in QTextEngine::shapeTextWithHarfbuzz (this=0xa074f28, item=2) at text/qtextengine.cpp:1122
#18 0xb67fba8a in QTextEngine::shapeText (this=0xa074f28, item=2) at text/qtextengine.cpp:874
#19 0xb67fc0bb in QTextEngine::shape (this=0xa074f28, item=2) at text/qtextengine.cpp:1359
#20 0xb67feb52 in QTextEngine::shapeLine (this=0xa074f28, line=@0x998ffb8) at text/qtextengine.cpp:844
#21 0xb6808bef in QTextLine::cursorToX (this=0xbfe9b688, cursorPos=0xbfe9b674, edge=QTextLine::Leading) at text/qtextlayout.cpp:2301
#22 0xb67f5c41 in QTextLine::cursorToX (this=0xbfe9b688, cursorPos=0, edge=QTextLine::Leading) at ../../include/QtGui/../../src/gui/text/qtextlayout.h:218
#23 0xb6868401 in QTextCursorPrivate::setX (this=0xa05cd40) at text/qtextcursor.cpp:143
#24 0xb68698ce in QTextCursorPrivate::movePosition (this=0xa05cd40, op=QTextCursor::Start, mode=QTextCursor::MoveAnchor) at text/qtextcursor.cpp:644
#25 0xb686baf2 in QTextCursor::movePosition (this=0xbfe9b91c, op=QTextCursor::Start, mode=QTextCursor::MoveAnchor, n=1) at text/qtextcursor.cpp:1204
#26 0xb686bf6c in QTextCursor::select (this=0xbfe9b91c, selection=QTextCursor::Document) at text/qtextcursor.cpp:1453
#27 0x08093bae in XliffTextEdit::toPlainText (this=0x9177360) at /usr/local/trunk-src/kdesdk/lokalize/src/xlifftextedit.cpp:841
#28 0x08097b11 in XliffTextEdit::contentsChanged (this=0x9177360, offset=0, charsRemoved=141, charsAdded=141) at /usr/local/trunk-src/kdesdk/lokalize/src/xlifftextedit.cpp:391
#29 0x080985d6 in XliffTextEdit::qt_metacall (this=0x9177360, _c=QMetaObject::InvokeMetaMethod, _id=41, _a=0xbfe9bb44) at /home/annma/build/kdesdk/lokalize/src/xlifftextedit.moc:196
#30 0xb62541f5 in QMetaObject::metacall (object=0x9177360, cl=QMetaObject::InvokeMetaMethod, idx=141, argv=0xbfe9bb44) at kernel/qmetaobject.cpp:237
#31 0xb6268b57 in QMetaObject::activate (sender=0x917a8b8, m=0xb6ff249c, local_signal_index=0, argv=0xbfe9bb44) at kernel/qobject.cpp:3294
#32 0xb6d7704c in QTextDocument::contentsChange (this=0x917a8b8, _t1=0, _t2=141, _t3=141) at .moc/debug-shared/moc_qtextdocument.cpp:188
#33 0xb6833923 in QTextDocumentPrivate::finishEdit (this=0x917a8c8) at text/qtextdocument_p.cpp:1141
#34 0xb6833692 in QTextDocumentPrivate::endEditBlock (this=0x917a8c8) at text/qtextdocument_p.cpp:1125
#35 0xb6869c31 in QTextCursor::endEditBlock (this=0xbfe9bc54) at text/qtextcursor.cpp:2384
#36 0xb6882f67 in QSyntaxHighlighterPrivate::rehighlight (this=0x917dd48, cursor=@0xbfe9bc54, operation=QTextCursor::End) at text/qsyntaxhighlighter.cpp:76
#37 0xb6882062 in QSyntaxHighlighter::rehighlight (this=0x917d580) at text/qsyntaxhighlighter.cpp:381
#38 0xb7a87eed in Sonnet::Highlighter::slotRehighlight (this=0x917d580) at /usr/local/trunk-src/kdelibs/kdeui/sonnet/highlighter.cpp:168
#39 0xb7a893ec in Sonnet::Highlighter::qt_metacall (this=0x917d580, _c=QMetaObject::InvokeMetaMethod, _id=3, _a=0xbfe9bda4) at /home/annma/build/kdelibs/kdeui/highlighter.moc:83
#40 0x0809be02 in SyntaxHighlighter::qt_metacall (this=0x917d580, _c=QMetaObject::InvokeMetaMethod, _id=11, _a=0xbfe9bda4) at /home/annma/build/kdesdk/lokalize/src/syntaxhighlighter.moc:69
#41 0xb62541f5 in QMetaObject::metacall (object=0x917d580, cl=QMetaObject::InvokeMetaMethod, idx=11, argv=0xbfe9bda4) at kernel/qmetaobject.cpp:237
#42 0xb6268b57 in QMetaObject::activate (sender=0x91856c0, m=0xb63986e4, local_signal_index=0, argv=0x0) at kernel/qobject.cpp:3294
#43 0xb62cfd4b in QTimer::timeout (this=0x91856c0) at .moc/debug-shared/moc_qtimer.cpp:134
#44 0xb6272a9c in QTimer::timerEvent (this=0x91856c0, e=0xbfe9c42c) at kernel/qtimer.cpp:271
#45 0xb62636f6 in QObject::event (this=0x91856c0, e=0xbfe9c42c) at kernel/qobject.cpp:1224
#46 0xb6504f74 in QApplicationPrivate::notify_helper (this=0x8a3aa08, receiver=0x91856c0, e=0xbfe9c42c) at kernel/qapplication.cpp:4242
#47 0xb65053c3 in QApplication::notify (this=0xbfe9c74c, receiver=0x91856c0, e=0xbfe9c42c) at kernel/qapplication.cpp:3661
#48 0xb7a0e5f3 in KApplication::notify (this=0xbfe9c74c, receiver=0x91856c0, event=0xbfe9c42c) at /usr/local/trunk-src/kdelibs/kdeui/kernel/kapplication.cpp:302
#49 0xb624c910 in QCoreApplication::notifyInternal (this=0xbfe9c74c, receiver=0x91856c0, event=0xbfe9c42c) at kernel/qcoreapplication.cpp:704
#50 0xb6500d05 in QCoreApplication::sendEvent (receiver=0x91856c0, event=0xbfe9c42c) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215
#51 0xb628a7d6 in QTimerInfoList::activateTimers (this=0x8a3da3c) at kernel/qeventdispatcher_unix.cpp:603
#52 0xb6288016 in timerSourceDispatch (source=0x8a3da08) at kernel/qeventdispatcher_glib.cpp:184
#53 0xb628804b in idleTimerSourceDispatch (source=0x8a3da78) at kernel/qeventdispatcher_glib.cpp:231
#54 0xb59d27ca in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#55 0xb59d5ee8 in ?? () from /usr/lib/libglib-2.0.so.0
#56 0xb59d60a8 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#57 0xb6286eea in QEventDispatcherGlib::processEvents (this=0x8a3a9e8, flags={i = -1075198456}) at kernel/qeventdispatcher_glib.cpp:407
#58 0xb65f5792 in QGuiEventDispatcherGlib::processEvents (this=0x8a3a9e8, flags={i = -1075198408}) at kernel/qguieventdispatcher_glib.cpp:202
#59 0xb6248cb6 in QEventLoop::processEvents (this=0xbfe9c6d8, flags={i = -1075198332}) at kernel/qeventloop.cpp:149
#60 0xb6248f28 in QEventLoop::exec (this=0xbfe9c6d8, flags={i = -1075198240}) at kernel/qeventloop.cpp:201
#61 0xb624d265 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:981
#62 0xb6507d56 in QApplication::exec () at kernel/qapplication.cpp:3570
#63 0x08072d9b in main (argc=) at /usr/local/trunk-src/kdesdk/lokalize/src/main.cpp:117

Possible duplicates by query: bug 203180.

Reported using DrKonqi
Comment 1 Dario Andres 2009-12-11 13:28:31 UTC
From bug 203180:
---
What I was doing when the application crashed:
When adding text on the first line of t the fuzzy translation 849 in
trunk/kde-l10n/sv/messages/kxsconfig.po, Lokalize crashes. The crash is caused
by an assert in Qt 4.5.1.
Comment 2 Dario Andres 2009-12-11 13:28:34 UTC
*** Bug 203180 has been marked as a duplicate of this bug. ***
Comment 3 stefan.asserhall 2009-12-19 15:48:54 UTC
Created attachment 39174 [details]
Fix for the crash

This patch fixes the crash for me. It seems that the root cause of the crash is an attempt to select text using a cursor while a rehighlight is in progress.
Comment 4 Nick Shaforostoff 2009-12-20 01:01:13 UTC
this patch would introduce regression for bug 162016.

what is strange is that Sonnet::Highlighter::slotRehighlight triggers contentsChange signal.

does adding the following code to the very begginning of XliffTextEdit::contentsChanged fixes this crash for you?

QString asciiText=document()->toPlainText();
if (KDE_ISUNLIKELY( m_currentPos.entry==-1 || asciiText==oldMsgstr.replace(QChar::Nbsp, ' ') ))
   {
        return;
   }
Comment 5 stefan.asserhall 2009-12-20 11:07:00 UTC
Yes, it seems that adding this code to the beginning of XliffTextEdit::contentsChanged also fixes the bug. That is logical, since this code also avoids reaching the text selection using the cursor, which causes the crash.
Comment 6 Nick Shaforostoff 2009-12-20 14:22:51 UTC
SVN commit 1064264 by shaforo:

BUG: 218246
workaround Qt design issue (it is unsafe to select all the document in its contentsChange handler)



 M  +9 -0      xlifftextedit.cpp  
 M  +1 -0      xlifftextedit.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1064264
Comment 7 Nick Shaforostoff 2009-12-20 14:25:08 UTC
*** Bug 204778 has been marked as a duplicate of this bug. ***