Summary: | konsole hangs after inserting text | ||
---|---|---|---|
Product: | [Applications] konsole | Reporter: | P A S <p.a.s> |
Component: | general | Assignee: | Konsole Developer <konsole-devel> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | andresbajotierra, andy_minn, christophe, gassauer, kde, ossi, robertknight, sven.burmeister, torleif, ufleisch, vide80 |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | PTY master file descriptor non-blocking |
Description
P A S
2008-06-25 17:22:19 UTC
> After that, Konsole hangs forever. If you leave Konsole for a couple of minutes or so does it respond? This might be a duplicate of http://bugs.kde.org/show_bug.cgi?id=163445 Does running "killall knotify4" unfreeze Konsole? I tried to paste a very long command for compilation (12000 chars) and I suffer the same symptoms (22 minutes hanged at the momentof writing). «killall knotify4» does not unfreeze Konsole. Also, I cannot open a new Konsole window from «Kickoff» of «Alt+F2» when it is hanged. I can from xterm typing «konsole». I waited now 10 minutes and nothing changed. Also "killall knotify4" didn't help. > I tried to copy the xorg.conf example from
Copy it into vim or another terminal text editor you mean?
Yes, for example. I tried to copy it in the mc text editor, but you can just copy it to the prompt. Source is the opened page in a web browser (konqueror4 or firefox3). Konsole Version 2.1 Using KDE 4.1.00 (KDE 4.0.99 (4.1 RC1+)) (KDEmod) in ArchLinux Using the html code of the example URL (~2400 lines). Paste the text in nano editor inside Konsole took 7 seconds, but pasting the text into VIM inside Konsole seems to hangup all the Konsole windows While loading the text into VIM: At first, VIM process showed some CPU usage but later: Konsole, bash and VIM showed 0% cpu usage and its memory use remained the same Inside gnome-terminal, pasting the text in nano took nearly the same time, and pasting in VIM took ~30secs (during that time, the VIM process was eating a lot of CPU) Version 2.1 Using KDE 4.1.00 (KDE 4.1.0) final (KDEmod) in ArchLinux i686 Using all the html code of the example URL (~2400 lines) Pasting the text in nano took 7 seconds. Pasting the text in VIM took ~1.5sec (I noticed that I have removed my vimrc). Restoring my vimrc to my home dir, Konsole seems to hangup :(. So it seems to be a problem related to some vimrc option (at least in VIM) My vimrc (taken from some web sample): "Sample .vimrc set nocompatible set showmatch set incsearch set ignorecase set smartcase set history=100 set backspace=eol,start,indent "set ruler set tabstop=4 set shiftwidth=4 set expandtab set virtualedit=all set background=dark set vb t_vg= set mouse=v set textwidth=79 set formatoptions=tcrq set complete=.,t,i,b,w,k ----- Pasting the XOrg.conf example of the test webpage directly in Konsole shell freezed the app. (while using 0% CPU). (29 minutes of hangup and counting, seems to be an infinite loop) Experience this too with KDE 4.1.0, Gentoo. *** This bug has been confirmed by popular vote. *** This also applies to Fedora 9 running KDE 4.1.0-1. Typically pasting more than 70 lines of code to konsole causes it to freeze. 'killall knotify4' does not unfreeze konsole. The bugs still exists in KDE 4.1.1 (Ubuntu packages). I was pasting a ~50k text and konsole got totally frozen. Please at least confirm the bug in Bugzilla. Deleting ~/.kde solved the problem for me. However this made kmail (in kdepim 3.5.9-10) unable to send messages through smtp. Because you just deleted all settings for your KDE3 application, if you were lucky and your distro uses .kde4 for KDE4 applications. Otherwise you just deleted all settings for all of your KDE applications. If your mail was stored at the default place, i.e. ~/.kde/share/apps/kmail it would be gone too. Yes. That was my intention; to delete all settings for all kde-apps. It solved this bug, and dont be concerned; I have my email, and kmail is again up and running again. This happened in KDE 4.1.1 even with 130 lines pasted! This is a REALLY serious bug... please take a look at it because IMO it could be considered a showstopper. Bug is back here. FYI I was pasting a shell script in a local bash prompt, no editors opened at all. Hello, I can confirm this. Konsole is hanging when writing data to the terminal with write() in kdelibs/kpty/kptydevice.cpp:306 . The write() call is blocking. If I do something which causes signals to interrupt the write call, like resizing the terminal window, then the write process continues bit-by-bit. Ossi - any ideas before I dig into this further? Had a closer look - it seems that problems start happening when trying to write more than 4KB at once to the terminal, which is the chunk size for KPty's internal ring buffer. I can confirm this. If more than 4095 bytes are pasted, konsole hangs. It seems to hang in the write system call of KPtyDevicePrivate::_k_canWrite(). I set the filedescriptor to non-blocking mode using "fcntl(q->masterFd(), F_SETFL, O_NONBLOCK)" before the write, and konsole did not hang anymore. Because I am not a pty expert, I do not claim that this is the solution (konsole could swallow some bytes), but maybe a starting point. Hi, The patch below sets the master PTY file descriptor to non-blocking mode and handles the EAGAIN errors which are then possible. With that patch applied I was able to paste large amounts of text into konsole without problems. ~~~~~~~~~ Index: kpty/kptydevice.cpp =================================================================== --- kpty/kptydevice.cpp (revision 882922) +++ kpty/kptydevice.cpp (working copy) @@ -30,6 +30,7 @@ #include <klocale.h> #include <unistd.h> +#include <fcntl.h> #include <errno.h> #include <signal.h> #include <termios.h> @@ -273,7 +274,10 @@ char *ptr = readBuffer.reserve(available); NO_INTR(readBytes, read(q->masterFd(), ptr, available)); if (readBytes < 0) { - q->setErrorString(I18N_NOOP("Error reading from PTY")); + if (errno != EAGAIN) { + q->setErrorString(I18N_NOOP("Error reading from PTY")); + } + readBuffer.unreserve(available); return false; } readBuffer.unreserve(available - readBytes); // *should* be a no-op @@ -307,7 +311,11 @@ write(q->masterFd(), writeBuffer.readPointer(), writeBuffer.readSize())); if (wroteBytes < 0) { - q->setErrorString(I18N_NOOP("Error writing to PTY")); + if (errno != EAGAIN) { + q->setErrorString(I18N_NOOP("Error writing to PTY")); + } else { + writeNotifier->setEnabled(true); + } return false; } writeBuffer.free(wroteBytes); @@ -419,6 +427,7 @@ readBuffer.clear(); readNotifier = new QSocketNotifier(q->masterFd(), QSocketNotifier::Read, q); writeNotifier = new QSocketNotifier(q->masterFd(), QSocketNotifier::Write, q); + fcntl(q->masterFd(), F_SETFL, O_NONBLOCK); QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_k_canRead())); QObject::connect(writeNotifier, SIGNAL(activated(int)), q, SLOT(_k_canWrite())); readNotifier->setEnabled(true); ~~~~~~~~~ Regards, Urs Created attachment 28499 [details]
PTY master file descriptor non-blocking
I see this issue too, quite often. It freezes all konsole-windows when multiple are open. I am new to Linux and get this bug, too. How do I apply this patch (never done this before)? My impression is that I have to navigate to the "kpty" folder but I cannot find it. I am running Kubuntu. Thanks so much. KPty is in kdelibs. I have patched the sources from svn (kdesvn-build): cd ~/kdesvn/kdelibs/ patch -p0 <pty_nonblocking.diff To create a deb-package to be used with Kubuntu, get the kdelibs sources using "apt-get source" or download them and then extract them using "dpkg-source -x kde4libs-YOURVERSION.dsc". Then go into the extracted kde4libs directory, copy the patch into debian/patches and append it to the series file: cp pty_nonblocking.diff debian/patches/ echo "pty_nonblocking.diff -p0" >>debian/patches/series Now you can start the build using dpkg-buildpackage -rfakeroot missed this somehow ... yes, this is a classic deadlock: konsole writes to the child, the child responds with output and fills its end of the pty buffer, thus blocking at some point. as it is not accepting input from konsole any more, konsole's write will never finish. the EAGAIN handling should be unnecessary, as the notifiers only fire when the error would not happen and we don't loop on the fd (except for the EINTR loop, but that should not matter, either). i'll commit shortly. SVN commit 890839 by ossi: make PTY non-blocking to avoid deadlock. BUG: 164946 M +2 -0 kptydevice.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=890839 Thanks so much for the response. Since there is a "commit" and the status is "resolved", should I assume that an upgrade version of Konsole with the fix will be available soon that I will see using Adept? Sorry, I am sure these are really basic questions. > Since there is a "commit" and the status is "resolved", should I > assume that an upgrade version of Konsole with the fix will be available > soon that I will see using Adept? Not automatically I'm afraid. Since the patch in comment #28 is really simple I expect that the Kubuntu team would be prepared to make it available as an update. Has it been backported to KDE 4.1 branch? nope. feel free to do it. Unfortunately I don't have a compile-able KDE 4.1 checkout of kdelibs at the moment - can another developer who does please backport this and CC this bug please? test-compiling is for wussies. committed it now. :D *** Bug 170007 has been marked as a duplicate of this bug. *** |