Bug 276720 - Assert in screen emulation
Summary: Assert in screen emulation
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-29 00:30 UTC by Christoph Feck
Modified: 2011-07-03 14:13 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Feck 2011-06-29 00:30:41 UTC
I am trying to edit file "kdeplasma-addons/applets/systemloadviewer/plasma-applet-systemloadviewer.desktop" using the "nano" editor. When scrolling down, I get this crash/assert.

This is probably caused by the commit(s) for bug 96536 in master.

(gdb) bt
#0  0xffffe424 in __kernel_vsyscall ()
#1  0xb5d908df in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0xb5d92220 in abort () at abort.c:92
#3  0xb6f3e9d3 in qt_message_output (msgType=QtFatalMsg, buf=
    0x8326730 "ASSERT: \"(currentChar.rendition & RE_EXTENDED_CHAR) == 0\" in file /local/git/KDE/base/konsole/src/Screen.cpp, line 663")
    at /local/git/Qt/qt/src/corelib/global/qglobal.cpp:2282
#4  0xb6f3eb3e in qt_message (msgType=QtFatalMsg, msg=0xb70cb414 "ASSERT: \"%s\" in file %s, line %d", ap=0xbfffe384 "\354\235\367\267\244\234\367\267\227\002")
    at /local/git/Qt/qt/src/corelib/global/qglobal.cpp:2328
#5  0xb6f3ef6a in qFatal (msg=0xb70cb414 "ASSERT: \"%s\" in file %s, line %d") at /local/git/Qt/qt/src/corelib/global/qglobal.cpp:2511
#6  0xb6f3e578 in qt_assert (assertion=0xb7f79dec "(currentChar.rendition & RE_EXTENDED_CHAR) == 0", file=0xb7f79ca4 "/local/git/KDE/base/konsole/src/Screen.cpp", 
    line=663) at /local/git/Qt/qt/src/corelib/global/qglobal.cpp:2027
#7  0xb7f24d64 in Konsole::Screen::displayCharacter (this=0x81bc078, c=3656) at /local/git/KDE/base/konsole/src/Screen.cpp:663
#8  0xb7f67740 in Konsole::Vt102Emulation::processToken (this=0x81b0718, token=0, p=3656, q=0) at /local/git/KDE/base/konsole/src/Vt102Emulation.cpp:449
#9  0xb7f65f9c in Konsole::Vt102Emulation::receiveChar (this=0x81b0718, cc=3656) at /local/git/KDE/base/konsole/src/Vt102Emulation.cpp:321
#10 0xb7ef9429 in Konsole::Emulation::receiveData (this=0x81b0718, text=
    0x832a3c8 "\033[6Gro]=Vizualizator încărcare sistem\033[4;6Hru]=Загрузка системы\033[K\033[5;6Hsk]=Prehliadač záťaže systému\033[6;6Hsl]=Prikazovalnik obremenitve sistema\033[7;6Hsq]=Shfaqës i Ngarkesës s", <incomplete sequence \303>..., length=1047) at /local/git/KDE/base/konsole/src/Emulation.cpp:231
#11 0xb7f2d1d4 in Konsole::Session::onReceiveBlock (this=0x81c0e70, buf=
    0x832a3c8 "\033[6Gro]=Vizualizator încărcare sistem\033[4;6Hru]=Загрузка системы\033[K\033[5;6Hsk]=Prehliadač záťaže systému\033[6;6Hsl]=Prikazovalnik obremenitve sistema\033[7;6Hsq]=Shfaqës i Ngarkesës s", <incomplete sequence \303>..., len=1047) at /local/git/KDE/base/konsole/src/Session.cpp:1184
#12 0xb7f2e5c7 in Konsole::Session::qt_metacall (this=0x81c0e70, _c=QMetaObject::InvokeMetaMethod, _id=39, _a=0xbfffe604)
    at /local/build/KDE/base/konsole/src/Session.moc:222
#13 0xb705c43a in QMetaObject::metacall (object=0x81c0e70, cl=QMetaObject::InvokeMetaMethod, idx=43, argv=0xbfffe604)
    at /local/git/Qt/qt/src/corelib/kernel/qmetaobject.cpp:237
#14 0xb706f5bf in QMetaObject::activate (sender=0x81c8740, m=0xb7fb8cf8, local_signal_index=0, argv=0xbfffe604)
    at /local/git/Qt/qt/src/corelib/kernel/qobject.cpp:3278
#15 0xb7f21e0d in Konsole::Pty::receivedData (this=0x81c8740, _t1=
    0x832a3c8 "\033[6Gro]=Vizualizator încărcare sistem\033[4;6Hru]=Загрузка системы\033[K\033[5;6Hsk]=Prehliadač záťaže systému\033[6;6Hsl]=Prikazovalnik obremenitve sistema\033[7;6Hsq]=Shfaqës i Ngarkesës s", <incomplete sequence \303>..., _t2=1047) at /local/build/KDE/base/konsole/src/Pty.moc:97
#16 0xb7f21b1d in Konsole::Pty::dataReceived (this=0x81c8740) at /local/git/KDE/base/konsole/src/Pty.cpp:272
#17 0xb7f21da7 in Konsole::Pty::qt_metacall (this=0x81c8740, _c=QMetaObject::InvokeMetaMethod, _id=4, _a=0xbfffe6dc) at /local/build/KDE/base/konsole/src/Pty.moc:85
#18 0xb705c43a in QMetaObject::metacall (object=0x81c8740, cl=QMetaObject::InvokeMetaMethod, idx=30, argv=0xbfffe6dc)
    at /local/git/Qt/qt/src/corelib/kernel/qmetaobject.cpp:237
#19 0xb706f5bf in QMetaObject::activate (sender=0x81b6298, m=0xb71d6c28, local_signal_index=0, argv=0x0) at /local/git/Qt/qt/src/corelib/kernel/qobject.cpp:3278
#20 0xb70c4f59 in QIODevice::readyRead (this=0x81b6298) at .moc/debug-shared/moc_qiodevice.cpp:91
#21 0xb7e9a61c in KPtyDevicePrivate::_k_canRead (this=0x81a7ea8) at /local/git/KDE/libs/kdelibs/kpty/kptydevice.cpp:335
#22 0xb7e9b46e in KPtyDevice::qt_metacall (this=0x81b6298, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0xbfffe878)
    at /local/build/KDE/libs/kdelibs/kpty/kptydevice.moc:80
#23 0xb705c43a in QMetaObject::metacall (object=0x81b6298, cl=QMetaObject::InvokeMetaMethod, idx=9, argv=0xbfffe878)
    at /local/git/Qt/qt/src/corelib/kernel/qmetaobject.cpp:237
#24 0xb706f5bf in QMetaObject::activate (sender=0x81af148, m=0xb71d7530, local_signal_index=0, argv=0xbfffe878)
    at /local/git/Qt/qt/src/corelib/kernel/qobject.cpp:3278
#25 0xb70c7464 in QSocketNotifier::activated (this=0x81af148, _t1=14) at .moc/debug-shared/moc_qsocketnotifier.cpp:89
#26 0xb707752f in QSocketNotifier::event (this=0x81af148, e=0xbfffee08) at /local/git/Qt/qt/src/corelib/kernel/qsocketnotifier.cpp:317
#27 0xb632e8ae in QApplicationPrivate::notify_helper (this=0x8078828, receiver=0x81af148, e=0xbfffee08) at /local/git/Qt/qt/src/gui/kernel/qapplication.cpp:4462
#28 0xb632c1aa in QApplication::notify (this=0xbffff0b8, receiver=0x81af148, e=0xbfffee08) at /local/git/Qt/qt/src/gui/kernel/qapplication.cpp:3862
[...]
Comment 1 Albert Astals Cid 2011-06-29 08:08:38 UTC
There is indeed a problem when rendering the Name[th] for that file

This patch seems like it would be the correct thing to do

diff --git a/src/Screen.cpp b/src/Screen.cpp
index 03a4bbd..acb0303 100644
--- a/src/Screen.cpp
+++ b/src/Screen.cpp
@@ -660,10 +660,28 @@ void Screen::displayCharacter(unsigned short c)
             charToCombineWithY = cuY;
         }
         Character& currentChar = screenLines[charToCombineWithY][charToCombineWithX];
-        Q_ASSERT((currentChar.rendition & RE_EXTENDED_CHAR) == 0);
-        const ushort chars[2] = { currentChar.character, c };
-        currentChar.rendition |= RE_EXTENDED_CHAR;
-        currentChar.character = ExtendedCharTable::instance.createExtendedChar(chars, 2);
+        if ((currentChar.rendition & RE_EXTENDED_CHAR) == 0)
+        {
+            const ushort chars[2] = { currentChar.character, c };
+            currentChar.rendition |= RE_EXTENDED_CHAR;
+            currentChar.character = ExtendedCharTable::instance.createExtendedChar(chars, 2);
+        }
+        else
+        {
+            ushort extendedCharLength;
+            const ushort* oldChars = ExtendedCharTable::instance.lookupExtendedChar(currentChar.character, extendedCharLength);
+            Q_ASSERT(oldChars);
+            if (oldChars)
+            {
+                Q_ASSERT(extendedCharLength > 1);
+                Q_ASSERT(extendedCharLength < 65535);
+                ushort *chars = new ushort[extendedCharLength + 1];
+                memcpy (chars, oldChars, sizeof(ushort) * extendedCharLength);
+                chars[extendedCharLength] = currentChar.character;
+                currentChar.character = ExtendedCharTable::instance.createExtendedChar(chars, extendedCharLength);
+                delete[] chars;
+            }
+        }
         return;
     }

But actually gives a somewhat worse rendering than the old konsole so i have to research a bit how th works and what kind of characters are trying to be composed. I'm a bit busy the coming days so not sure i'll be able of having a look before next monday
Comment 2 Albert Astals Cid 2011-06-29 09:16:08 UTC
Booo, the patch is obviously wrong
chars[extendedCharLength] = currentChar.character;
should be
chars[extendedCharLength] = c;

Maybe with that it will work better but can not say since i'm away from my compilation machine right now
Comment 3 Michael Jansen 2011-06-30 16:27:38 UTC
Amarok Master:

grep -i nepomuk ./src/core-impl/collections/nepomukcollection/amarok_collection-nepomukcollection.desktop

triggers the bug for me. The patch fixes the problem. kate has problems showing that file too.
Comment 4 Nicolás Alvarez 2011-06-30 17:04:09 UTC
I don't have a debug konsole to test, but this might be enough to crash it:

/usr/bin/printf '\u0e2a\u0e37\u0e48\n'

It may be worth noting that it seems to be the only character in that .desktop file that has *two* combining diacritics composed over the base character, and the second diacritic is which causes the assertion (I see c=3656 in the backtrace, which is 0x0e48).
Comment 5 Albert Astals Cid 2011-07-03 14:13:01 UTC
Nicolas, it was pretty obvious that it was the second combining character causing the assertion ;-)

Anyway, i've commited the patch to trunk now, it should be working again, sorry for the delay.