Error when calling Amarok::decapitateString()

Nicholas Sinlock isolatedincident at gmail.com
Thu Jan 8 18:01:50 UTC 2009


Pavel Shved wrote:
> Nicholas Sinlock wrote:
>
>> According to the crash handler, and some testing on my part, the 
>> crash appears to be originating in the decapitateString function
>> and, if I'm reading it correctly, having something to do with the 
>> chName string.   But no matter what I do, even if I use a simple
>> quoted string, like "60 Second Science", I recieve the same error.   
>> Here's the decapitateString function code.
>>
>>     QString decapitateString( const QString &input, const QString &ref )
>
> Apart from how decapitateString() is called it obviously aims to strip 
> common prefix of two strings from input string, then strip non-word 
> characters from the beginning and return the result.  In order to 
> obfuscate code (i can't imagine any other reason) it is written in 
> obscure, non-effective and longer way.
>
> ref.at(t.length() ) is sometimes out of range in this condition here
>
>>         if( t.endsWith( ' ' ) || !ref.at( t.length() 
>
> as t is the common prefix of strings and it may sometimes coincide 
> with one (or both--which is your case obviously) of them.
>
> Fix it like that:
>
> > if( !t.length()>=ref.length()) if (t.endsWith( ' ' ) || !ref.at( 
> t.length()
>
> or completely rewrite the function (better solution imho).
>
> Probably, the coder was confused that QString::left() function accepts 
> range violation and extrapolated it to at() function, that doesn't.
>
> And probably problem isn't in this particular function because, if it 
> is called with particular parameters, it works ok.  The problem may be 
> in caller, so the backtrace (as already asked for by the other poster) 
> may be useful for developers.
>
I believe I am building it with full debug.  Here's the backtrace.  At 
least, I believe this is what you mean.

Thread 1 (Thread 0xb4412700 (LWP 11300)):

[KCrash Handler]

#6  0xffffe430 in __kernel_vsyscall ()
#7  0xb6817990 in raise () from /lib/libc.so.6
#8  0xb68192c8 in abort () from /lib/libc.so.6
#9  0xb6ad68d5 in qt_message_output(QtMsgType, char const*) () from 
/usr/lib/libQtCore.so.4
#10 0xb6ad69b2 in qFatal(char const*, ...) () from /usr/lib/libQtCore.so.4
#11 0xb6ad6a45 in qt_assert(char const*, char const*, int) () from 
/usr/lib/libQtCore.so.4
#12 0xb79ed2cc in QString::at (this=0xbfa34604, i=17) at 
/usr/include/QtCore/qstring.h:644
#13 0xb7a80a98 in Amarok::decapitateString (input=@0xbfa34600, 
ref=@0xbfa34604) at 
/home/nsinlock/kde/sources/trunk/extragear/multimedia/amarok/src/App.cpp:1011
#14 0xb7a5384d in PlaylistBrowserNS::PodcastModel::data (this=0x8998728, 
index=@0xbfa34954, role=1)
    at 
/home/nsinlock/kde/sources/trunk/extragear/multimedia/amarok/src/browsers/playlistbrowser/PodcastModel.cpp:85
#15 0xb75c0383 in 
QStyledItemDelegate::initStyleOption(QStyleOptionViewItem*, QModelIndex 
const&) const () from /usr/lib/libQtGui.so.4
#16 0xb75c12b4 in QStyledItemDelegate::sizeHint(QStyleOptionViewItem 
const&, QModelIndex const&) const () from /usr/lib/libQtGui.so.4
#17 0xb75529d9 in QTreeView::indexRowSizeHint(QModelIndex const&) const 
() from /usr/lib/libQtGui.so.4
#18 0xb7552d52 in ?? () from /usr/lib/libQtGui.so.4
#19 0xb7553010 in ?? () from /usr/lib/libQtGui.so.4
#20 0xb7553392 in QTreeView::updateGeometries() () from 
/usr/lib/libQtGui.so.4
#21 0xb755c9c2 in QTreeView::mousePressEvent(QMouseEvent*) () from 
/usr/lib/libQtGui.so.4
#22 0xb7a560e6 in PlaylistBrowserNS::PodcastView::mousePressEvent 
(this=0x88d9e80, event=0xbfa35388)
    at 
/home/nsinlock/kde/sources/trunk/extragear/multimedia/amarok/src/browsers/playlistbrowser/PodcastCategory.cpp:315
#23 0xb70a8a49 in QWidget::event(QEvent*) () from /usr/lib/libQtGui.so.4
#24 0xb73dea83 in QFrame::event(QEvent*) () from /usr/lib/libQtGui.so.4
#25 0xb74751bf in QAbstractScrollArea::viewportEvent(QEvent*) () from 
/usr/lib/libQtGui.so.4
#26 0xb751ff3f in QAbstractItemView::viewportEvent(QEvent*) () from 
/usr/lib/libQtGui.so.4
#27 0xb7557ae4 in QTreeView::viewportEvent(QEvent*) () from 
/usr/lib/libQtGui.so.4
#28 0xb7477765 in ?? () from /usr/lib/libQtGui.so.4
#29 0xb6bcdb3a in 
QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, 
QEvent*) () from /usr/lib/libQtCore.so.4
#30 0xb70508da in QApplicationPrivate::notify_helper(QObject*, QEvent*) 
() from /usr/lib/libQtGui.so.4
#31 0xb7059111 in QApplication::notify(QObject*, QEvent*) () from 
/usr/lib/libQtGui.so.4
#32 0xb7d6b0a3 in KApplication::notify (this=0xbfa35c20, 
receiver=0x88daac8, event=0xbfa35388) at 
/home/nsinlock/kde/sources/trunk/KDE/kdelibs/kdeui/kernel/kapplication.cpp:307
#33 0xb6bce961 in QCoreApplication::notifyInternal(QObject*, QEvent*) () 
from /usr/lib/libQtCore.so.4
#34 0xb705839e in QApplicationPrivate::sendMouseEvent(QWidget*, 
QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&) () from 
/usr/lib/libQtGui.so.4
#35 0xb70c2716 in ?? () from /usr/lib/libQtGui.so.4
#36 0xb70c1ac5 in QApplication::x11ProcessEvent(_XEvent*) () from 
/usr/lib/libQtGui.so.4
#37 0xb70ea08a in ?? () from /usr/lib/libQtGui.so.4
#38 0xb492f9a8 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#39 0xb4933063 in ?? () from /usr/lib/libglib-2.0.so.0
#40 0xb4933221 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#41 0xb6bf8fb8 in 
QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 
() from /usr/lib/libQtCore.so.4
#42 0xb70e9785 in ?? () from /usr/lib/libQtGui.so.4
#43 0xb6bcd01a in 
QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from 
/usr/lib/libQtCore.so.4
#44 0xb6bcd1da in 
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from 
/usr/lib/libQtCore.so.4
#45 0xb6bcf895 in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4
#46 0xb7050777 in QApplication::exec() () from /usr/lib/libQtGui.so.4
#47 0x0804bf37 in main (argc=1, argv=0xbfa36124) at 
/home/nsinlock/kde/sources/trunk/extragear/multimedia/amarok/src/main.cpp:130




More information about the Amarok mailing list