Bug 72830 - Crash when switching between compiling output levels
Summary: Crash when switching between compiling output levels
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Output Views (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KDevelop Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-17 17:29 UTC by András Manţia
Modified: 2004-02-06 13:48 UTC (History)
1 user (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 András Manţia 2004-01-17 17:29:15 UTC
1. Compile a project (large enough) with "Very Short Compiling Output" turned 
on. 
2. After done, switch to Short/Full Compiling output. This will take a lot of 
time. 
3. Now switch back to the Very Short output. KDevelop crashes. 
 
Backtrace will be attached soon.
Comment 1 András Manţia 2004-01-17 18:08:30 UTC
Subject: 
BT for crash. Actually I was wrong as it crash when pressing the RMB, before 
you are able to select the "Very Short Compiler Output". Seems like an out of 
memory issue (I have 768MB) which shows together with the slow switching from 
Very Short to Full/Short a very inefficient coding.


0x41a6c691 in kill () from /lib/libc.so.6
(gdb) bt
#0  0x41a6c691 in kill () from /lib/libc.so.6
#1  0x418ee511 in pthread_kill () from /lib/libpthread.so.0
#2  0x418ee83b in raise () from /lib/libpthread.so.0
#3  0x41a6c424 in raise () from /lib/libc.so.6
#4  0x41a6da50 in abort () from /lib/libc.so.6
#5  0x419ef2e5 in __cxxabiv1::__terminate(void (*)()) () 
from /usr/lib/libstdc++.so.5
#6  0x419ef322 in std::terminate() () from /usr/lib/libstdc++.so.5
#7  0x419ef4a2 in __cxa_throw () from /usr/lib/libstdc++.so.5
#8  0x419ef6df in operator new(unsigned) () from /usr/lib/libstdc++.so.5
#9  0x419ef7ad in operator new[](unsigned) () from /usr/lib/libstdc++.so.5
#10 0x415665f2 in QString::setLength(unsigned) (this=0xbfffe9f0, 
newLen=134271874) at tools/qstring.cpp:1699
#11 0x4156687b in QString::grow(unsigned) (this=0xbfffe9f0, newLen=134271874) 
at tools/qstring.cpp:1790
#12 0x4156ccb7 in QString::operator+=(QString const&) (this=0xbfffe9f0, 
str=@0xbfffe900) at tools/qstring.cpp:5339
#13 0x412ce169 in QTextDocument::plainText() const (this=0x8311e00) at 
kernel/qrichtext.cpp:2275
#14 0x412cf7b1 in QTextDocument::text() const (this=0x8311e00) at 
kernel/qrichtext.cpp:2455
#15 0x41301301 in QTextDocument::originalText() const (this=0x8311e00) at 
kernel/qrichtext_p.h:1823
#16 0x413efb51 in QTextEdit::text() const (this=0x8311a90) at 
widgets/qtextedit.cpp:3710
#17 0x413f52f4 in QTextEdit::createPopupMenu(QPoint const&) (this=0x8311a90, 
pos=@0xbfffeb1c)
    at widgets/qtextedit.cpp:5483
#18 0x41f75711 in MakeWidget::createPopupMenu(QPoint const&) (this=0x8311a90, 
pos=@0xbfffeb1c)
    
at /development/sources/kde-head/kdevelop/parts/outputviews/makewidget.cpp:673
#19 0x413eb81a in QTextEdit::contentsContextMenuEvent(QContextMenuEvent*) 
(this=0x8311a90, e=0xbfffeb10)
    at widgets/qtextedit.cpp:2651
#20 0x4139e93c in QScrollView::viewportContextMenuEvent(QContextMenuEvent*) 
(this=0x8311a90, e=0xbfffef70)
    at widgets/qscrollview.cpp:1884
#21 0x4139dcb5 in QScrollView::eventFilter(QObject*, QEvent*) (this=0x8311a90, 
obj=0x822b960, e=0xbfffef70)
    at widgets/qscrollview.cpp:1544
#22 0x413ecdd5 in QTextEdit::eventFilter(QObject*, QEvent*) (this=0x8311a90, 
o=0x822b960, e=0xbfffef70)
    at widgets/qtextedit.cpp:2908
#23 0x41278280 in QObject::activate_filters(QEvent*) (this=0x822b960, 
e=0xbfffef70) at kernel/qobject.cpp:902
#24 0x412780f2 in QObject::event(QEvent*) (this=0x822b960, e=0xbfffef70) at 
kernel/qobject.cpp:735
#25 0x412b26f3 in QWidget::event(QEvent*) (this=0x822b960, e=0xbfffef70) at 
kernel/qwidget.cpp:4630
#26 0x41218081 in QApplication::internalNotify(QObject*, QEvent*) 
(this=0xbffff500, receiver=0x822b960, e=0xbfffef70)
---Type <return> to continue, or q <return> to quit---
    at kernel/qapplication.cpp:2614
#27 0x41217be2 in QApplication::notify(QObject*, QEvent*) (this=0xbffff500, 
receiver=0x822b960, e=0xbfffef70)
    at kernel/qapplication.cpp:2457
#28 0x40d8b73d in KApplication::notify(QObject*, QEvent*) () 
from /opt/kde-cvs/lib/libkdecore.so.4
#29 0x411ae79b in QApplication::sendSpontaneousEvent(QObject*, QEvent*) 
(receiver=0x822b960, event=0xbfffef70)
    at kernel/qapplication.h:493
#30 0x411a77ee in QETWidget::translateMouseEvent(_XEvent const*) 
(this=0x822b960, event=0xbffff380)
    at kernel/qapplication_x11.cpp:4228
#31 0x411a541f in QApplication::x11ProcessEvent(_XEvent*) (this=0xbffff500, 
event=0xbffff380)
    at kernel/qapplication_x11.cpp:3387
#32 0x411bf940 in QEventLoop::processEvents(unsigned) (this=0x80ed250, 
flags=4) at kernel/qeventloop_x11.cpp:192
#33 0x4122c232 in QEventLoop::enterLoop() (this=0x80ed250) at 
kernel/qeventloop.cpp:198
#34 0x4122c14e in QEventLoop::exec() (this=0x80ed250) at 
kernel/qeventloop.cpp:145
#35 0x41218201 in QApplication::exec() (this=0xbffff500) at 
kernel/qapplication.cpp:2737
#36 0x08066283 in main (argc=1, argv=0xbffff674) 
at /development/sources/kde-head/kdevelop/src/main.cpp:128
#37 0x41a588ae in __libc_start_main () from /lib/libc.so.6

Comment 2 Andreas Scherf 2004-01-23 02:02:03 UTC
Yes, i have the same problem (compiling from source). It eats all my memory and crashes after switching the compiling output modes ..
Comment 3 Jens Dagerbo 2004-01-23 06:42:51 UTC
Hmm.. inefficient, yes.. But it's actually QTextEdit that's blowing up. I believe this is the line that does it:

> popup->setItemEnabled( d->id[ IdSelectAll ], (bool)text().length() );

It's pushing all of the widgets contents into a QString only to call length() on it to make sure it isn't zero.. Doesn't seem to be the most efficient way of doing it.. :)

Anyway, I think the real problem is that we use QTextEdit to host more data than it was designed for. Now that we're targetting Qt-3.2, we should try to use the LogText textformat, which is said to reduce memory consumption greatly. We might lose some of the nice formatting, but that's clearly preferable.

Comment 4 András Manţia 2004-01-23 09:11:12 UTC
Subject: Re:  Crash when switching between compiling output levels

> Hmm.. inefficient, yes.. But it's actually QTextEdit that's blowing up. I 
believe this is the line that does it:
> > popup->setItemEnabled( d->id[ IdSelectAll ], (bool)text().length() );
>
> It's pushing all of the widgets contents into a QString only to call
> length() on it to make sure it isn't zero.. Doesn't seem to be the most
> efficient way of doing it.. :)

Might be. But where is this code? I can't find it. Just because QTextEdit has 
a length method, so there is no need to call text() first. Oh, I see, it's in 
QTextEdit code. And idea would be to not call QTextEdit::createPopupMenu at 
all, just that we need to handle the Copy and Select All case in the 
makewidget in this case. Shouldn't be so hard.

Andras

Comment 5 Jens Dagerbo 2004-01-23 21:41:00 UTC
HEAD should perform better now. I'm curious to hear if it crashes. 
Comment 6 András Manţia 2004-01-25 16:26:53 UTC
Subject: Re:  Crash when switching between compiling output levels

Switching still takes several seconds from Very Short to Full, but it doesn't 
crash and I don't see an increase of the memory usage during this operation. 
Full->Short and Very Short->Short switching takes even longer, and the memory 
usage increased with 10MB.

After restarting KDevelop, I verified the memory usage: it uses 65 MB. 
Previously I started KDevelop, compiled the project (part of Quanta), 
switched between Full and Very Short and the memory usage was 71MB. As I 
stated switching again between Full->Short brought up the usage to 81MB. So 
it is still leaking memory somewhere, but it seems that uses much less than 
before.

Comment 7 Waldo Bastian 2004-01-29 18:12:39 UTC
QTextEdit::createPopupMenu() inefficiency reported to TrollTech.
Will be fixed for Qt > 3.3
Comment 8 Simon Hausmann 2004-02-06 13:48:40 UTC
Subject: qt-copy/src/widgets

CVS commit by hausmann: 

- don't call text().length() twice, in QTextEdit::createPopupMenu. It's
  terribly inefficient to do that when the content is large and gets
  converted to html. Instead now length() gets called instead, and only
  once. Patch will be in next release.

CCMAIL: 72830-done@bugs.kde.org


  M +3 -6      qtextedit.cpp   1.44


--- qt-copy/src/widgets/qtextedit.cpp  #1.43:1.44
@@ -5479,10 +5479,7 @@ QPopupMenu *QTextEdit::createPopupMenu( 
     popup->setItemEnabled( d->id[ IdPaste ], !isReadOnly() && !QApplication::clipboard()->text( d->clipboard_mode ).isEmpty() );
 #endif
-    popup->setItemEnabled( d->id[ IdClear ], !isReadOnly() && !text().isEmpty() );
-#ifdef QT_TEXTEDIT_OPTIMIZATION
-    popup->setItemEnabled( d->id[ IdSelectAll ], d->optimMode ? d->od->len : (bool)text().length() );
-#else
-    popup->setItemEnabled( d->id[ IdSelectAll ], (bool)text().length() );
-#endif
+    const bool isEmptyDocument = (length() == 0);
+    popup->setItemEnabled( d->id[ IdClear ], !isReadOnly() && !isEmptyDocument );
+    popup->setItemEnabled( d->id[ IdSelectAll ], !isEmptyDocument );
     return popup;
 #else