Bug 140855 - C-Style indentation causes crash when indentation is overwritten then undone.
Summary: C-Style indentation causes crash when indentation is overwritten then undone.
Status: RESOLVED WORKSFORME
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-29 22:12 UTC by Chris Le Sueur
Modified: 2007-04-03 15:52 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Test case for crash (88 bytes, text/x-c++src)
2007-02-01 00:32 UTC, Chris Le Sueur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Le Sueur 2007-01-29 22:12:05 UTC
Version:           2.5.5 (using KDE KDE 3.5.5)
Installed from:    Debian testing/unstable Packages
OS:                Linux

Under quite specific circumstances, trying to replace auto-indentation in kate can cause a crash.

You need to be in C-Style autoindentation, and tabs not spaces. Although if you swap spaces and tabs around, the bug might still exist. Here is a test case I created:

{
\tLine indented by one tab;
\tTab + no semicolon
\tPut four spaces [    ] into the clipboard.
\tPress enter at the end of this line, backspace, Ctrl-V, and then Ctrl-Z.

\tLook! The cursor is gone! Type something for explosion!
}

Where \t represents a tab.

To reproduce:

Load config as above, and load the test case.
Follow the instructions in the test case.
Kate will crash, with the following backtrace:

#0  0xb6f5542a in QString::insert () from /usr/lib/libqt-mt.so.3
#1  0xb6371fd2 in KateTextLine::insertText () from /usr/lib/kde3/libkatepart.so
#2  0xb63fbd22 in KateDocument::editInsertText () from /usr/lib/kde3/libkatepart.so
#3  0xb64081ff in KateDocument::insertText () from /usr/lib/kde3/libkatepart.so
#4  0xb6408778 in KateDocument::insertText () from /usr/lib/kde3/libkatepart.so
#5  0xb64188c5 in KateDocument::typeChars () from /usr/lib/kde3/libkatepart.so
#6  0xb6432893 in KateViewInternal::keyPressEvent () from /usr/lib/kde3/libkatepart.so
#7  0xb6411668 in KateViewInternal::eventFilter () from /usr/lib/kde3/libkatepart.so
#8  0xb6c38302 in QObject::activate_filters () from /usr/lib/libqt-mt.so.3
#9  0xb6c38380 in QObject::event () from /usr/lib/libqt-mt.so.3
#10 0xb6c6f612 in QWidget::event () from /usr/lib/libqt-mt.so.3
#11 0xb6bd0c26 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#12 0xb6bd2bda in QApplication::notify () from /usr/lib/libqt-mt.so.3
#13 0xb7381e0e in KApplication::notify () from /usr/lib/libkdecore.so.4
#14 0xb6b64495 in QApplication::sendSpontaneousEvent () from /usr/lib/libqt-mt.so.3
#15 0xb6b556f9 in QETWidget::translateKeyEvent () from /usr/lib/libqt-mt.so.3
#16 0xb6b61723 in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#17 0xb6b77d02 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#18 0xb6beb179 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#19 0xb6beaf9a in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#20 0xb6bd27bf in QApplication::exec () from /usr/lib/libqt-mt.so.3
#21 0xb7ed1c96 in kdemain () from /usr/lib/libkdeinit_kate.so
#22 0x08048482 in ?? ()
#23 0x00000001 in ?? ()
#24 0xbf8dc154 in ?? ()
#25 0xbf8dc0d8 in ?? ()
#26 0x080484f9 in ?? ()
#27 0xb7c91c8c in ?? () from /lib/tls/libc.so.6
#28 0xbf8dc0e0 in ?? ()
#29 0xbf8dc128 in ?? ()
#30 0xb7c9bea8 in __libc_start_main () from /lib/tls/libc.so.6
#31 0xb7c9bea8 in __libc_start_main () from /lib/tls/libc.so.6
#32 0x080483d1 in ?? ()

This seems to happen whenever the Autoindenter is about its business - when you press return, it inserts two extra tabs because there's no semicolon. When you backspace and paste in four spaces, it replaces those spaces - also in an odd way (you probably want to check that out ;) ) and when you undo, it goes to an intermediate step - after pasting, but before replacing.
At this point, the cursor disappears, and trying to type anything will produce the segfault. Note that pressing the cursor keys doesn't cause a crash.

Not a particularly common bug, I expect, but it does crop up when trying to do odd things with the autoindenter. (Trying to odd things being, using tabs for indentation and spaces for formatting)
Comment 1 Dominik Haumann 2007-01-31 18:10:27 UTC
To me it's not clear at all what to do to reproduce. Can you please split the instructions and the testcase? Best if you simply attach the test file to this report and tell what to do in which line when with which settings. Thanks :)
Comment 2 Chris Le Sueur 2007-02-01 00:13:59 UTC
OK, I've added the testcase properly. The config is as above, but I'll repeat it here for convenience - you must be using C-Style autoindentaiton, and, I think, using tabs not spaces. These appear to be the only requirements.
Again, for convenience, I'll repeat the general situation (I think I was in a rush when I posted above). The requirement of the test case is that the line does not have a semicolon, so that kate will indent the next line a few. It further needs something like braces, or some other C-syntax, for the autoindenter to kick in, it seems. Pasting in extra spaces makes kate convert them to tabs. Pressing undo takes you to this "intermediate step" where the spaces are pasted, but kate hasn't replaced them - at this point, the cursor disappears and typing segfaults.
Comment 3 Chris Le Sueur 2007-02-01 00:32:19 UTC
Created attachment 19494 [details]
Test case for crash

Instructions:
1 - put four spaces into the clipboard.
2 - go to line three.
3 - press enter.
4 - press Ctrl-V to paste.
5 - press Ctrl-Z to undo.
6 - try to type something. Kate will segfault.
Comment 4 Dominik Haumann 2007-02-01 07:35:03 UTC
I still can not reproduce. Maybe this somehow was fixed with the fix for bug #137157 ?
I use Gentoo/kdelibs-3.5.5-r7.
Comment 5 Christoph Cullmann 2007-04-03 15:52:49 UTC
Can't reproduce, too.
Seems to be fixed in KDE 3.5, /trunk has this stuff removed, therefor fixed there, too...