Bug 203092 - umbrello idl import crash
Summary: umbrello idl import crash
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-08 16:51 UTC by Wian Potgieter
Modified: 2013-11-06 17:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.8.0


Attachments
patch fixing the runtime error (683 bytes, patch)
2011-11-30 09:39 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wian Potgieter 2009-08-08 16:51:56 UTC
Application that crashed: umbrello
Version of the application: 2.3.0
KDE Version: 4.3.00 (KDE 4.3.0)
Qt Version: 4.5.1
Operating System: Linux 2.6.30-gentoo-r1 i686

What I was doing when the application crashed:
I tried to import the orb.idl file from http://www.omg.org/spec/CORBA/3.1/20030101 (you will need to download all the files)

I think the error is on line 83 of umbrello/umbrello/codeimport/idlimport.cpp.  Because i can be len-1, checking for word[i + 1] can cause the subscript to go out of bounds.

I have tested it by adding a check for i +1 being less than len.  It then crashes at other places (see below)

--SNIP--
void IDLImport::fillSource(const QString& word)
{
    QString lexeme;
    const uint len = word.length();
    for (uint i = 0; i < len; ++i) {
        QChar c = word[i];
        if (c.isLetterOrNumber() || c == '_') {
            lexeme += c;
        } else if (c == ':' && i+1 < len && word[i + 1] == ':') { // HERE!
            // compress scoped name into lexeme
            lexeme += "::";
            i++;
        } else if (c == '<') {
            // compress sequence or bounded string into lexeme
            do {
                lexeme += word[i];
            } while (word[i] != '>' && ++i < len);
        } else {
            if (!lexeme.isEmpty()) {
                m_source.append(lexeme);
                lexeme.clear();
            }
            m_source.append(QString(c));
        }
    }
    if (!lexeme.isEmpty())
        m_source.append(lexeme);
}
--SNIP-

Here is the backtrace for the new crash:
#0  0xb670cd19 in __dynamic_cast () from /usr/lib/gcc/i686-pc-linux-gnu/4.3.2/libstdc++.so.6                                
#1  0x0830bb50 in Model_Utils::findUMLObject (inList=@0xbfda5060, inName=@0xbfda517c, type=Uml::ot_Class, currentObj=0x20) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/model_utils.cpp:165
#2  0x083371d4 in UMLDoc::findUMLObject (this=0xa1e2d40, name=@0xbfda517c, type=Uml::ot_Class, currentObj=0x20) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/umldoc.cpp:826                
#3  0x0819fc94 in Import_Utils::createUMLObject (type=Uml::ot_Class, inName=@0xbfda52cc, parentPkg=0x20, comment=@0xa3a46f4, stereotype=@0xbfda52c8)                                                                            
    at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/codeimport/import_utils.cpp:176                                                                                                           
#4  0x0819d40a in IDLImport::parseStmt (this=0xa3a4658) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/codeimport/idlimport.cpp:182                                                          
#5  0x0819ce09 in IDLImport::parseFile (this=0xa3a4658, filename=@0xbfda54dc) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/codeimport/idlimport.cpp:152                                    
#6  0x0819c5fd in ClassImport::importFiles (this=0xa3a4658, fileList=@0xbfda5554) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/codeimport/classimport.cpp:45                               
#7  0x0831fa2e in UMLApp::importFiles (this=0xa1e2578, fileList=0xbfda5554) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/uml.cpp:2213                                                      
#8  0x0831fcde in UMLApp::slotImportClasses (this=0xa1e2578) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/uml.cpp:2250                                                                     
#9  0x0832aaed in UMLApp::qt_metacall (this=0xa1e2578, _c=QMetaObject::InvokeMetaMethod, _id=51, _a=0xbfda56ac) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0_build/umbrello/umbrello/uml.moc:276             
#10 0xb6b332c1 in QMetaObject::activate () from /usr/lib/qt4/libQtCore.so.4                                                                                                                                                     
#11 0xb6b335f1 in QMetaObject::activate () from /usr/lib/qt4/libQtCore.so.4                                                                                                                                                     
#12 0xb6cea4c2 in QAction::triggered () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                                         
#13 0xb6ceb78b in QAction::activate () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                                          
#14 0xb70fad9a in QMenuPrivate::activateCausedStack () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                          
#15 0xb71012f9 in QMenuPrivate::activateAction () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                               
#16 0xb71020f6 in QMenu::mouseReleaseEvent () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                                   
#17 0xb7a7f526 in KMenu::mouseReleaseEvent () from /usr/lib/libkdeui.so.5                                                                                                                                                       
#18 0xb6d4398a in QWidget::event () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                                             
#19 0xb7102bb1 in QMenu::event () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                                               
#20 0xb6cf000c in QApplicationPrivate::notify_helper () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                         
#21 0xb6cf8552 in QApplication::notify () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                                       
#22 0xb79966fe in KApplication::notify () from /usr/lib/libkdeui.so.5                                                                                                                                                           
#23 0xb6b20982 in QCoreApplication::notifyInternal () from /usr/lib/qt4/libQtCore.so.4                                                                                                                                          
#24 0xb6cf9a34 in QApplicationPrivate::sendMouseEvent () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                        
#25 0xb6d5afad in QETWidget::translateMouseEvent () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                             
#26 0xb6d598d5 in QApplication::x11ProcessEvent () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                              
#27 0xb6d80e12 in x11EventSourceDispatch () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                                     
#28 0xb5ffa398 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0                                                                                                                                                     
#29 0xb5ffdabb in g_main_context_iterate () from /usr/lib/libglib-2.0.so.0                                                                                                                                                      
#30 0xb5ffdc49 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0                                                                                                                                                    
#31 0xb6b48769 in QEventDispatcherGlib::processEvents () from /usr/lib/qt4/libQtCore.so.4                                                                                                                                       
#32 0xb6d80606 in QGuiEventDispatcherGlib::processEvents () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                     
#33 0xb6b1f0bb in QEventLoop::processEvents () from /usr/lib/qt4/libQtCore.so.4                                                                                                                                                 
#34 0xb6b1f29a in QEventLoop::exec () from /usr/lib/qt4/libQtCore.so.4                                                                                                                                                          
#35 0xb6b21521 in QCoreApplication::exec () from /usr/lib/qt4/libQtCore.so.4                                                                                                                                                    
#36 0xb6cefe78 in QApplication::exec () from /usr/lib/qt4/libQtGui.so.4                                                                                                                                                         
#37 0x083073e5 in main (argc=1, argv=0xbfda7854) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/main.cpp:111

Please let me know if there is anything you might need, or if I am working in the wrong direction.

Thanks!
  Wian Potgieter

 -- Backtrace:
Application: Umbrello UML Modeller (umbrello), signal: Aborted
[KCrash Handler]
#6  0xffffe424 in __kernel_vsyscall ()
#7  0xb648d9e1 in raise () from /lib/libc.so.6
#8  0xb648f25e in abort () from /lib/libc.so.6
#9  0xb69c52a5 in qt_message_output () from /usr/lib/qt4/libQtCore.so.4
#10 0xb69c5368 in qFatal () from /usr/lib/qt4/libQtCore.so.4
#11 0xb69c5426 in qt_assert () from /usr/lib/qt4/libQtCore.so.4
#12 0x0819be20 in QString::operator[] (this=0xbf9f2254, i=1) at /usr/include/qt4/QtCore/qstring.h:689
#13 0x0819eb2c in IDLImport::fillSource (this=0xa0d8c78, word=@0xbf9f2254) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/codeimport/idlimport.cpp:83
#14 0x081a5aee in NativeImportBase::scan (this=0xa0d8c78, line=@0xbf9f23f0) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/codeimport/nativeimportbase.cpp:328
#15 0x0819cc8c in IDLImport::parseFile (this=0xa0d8c78, filename=@0xbf9f246c) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/codeimport/idlimport.cpp:139
#16 0x0819c58d in ClassImport::importFiles (this=0xa0d8c78, fileList=@0xbf9f24e4) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/codeimport/classimport.cpp:45
#17 0x0831f7ce in UMLApp::importFiles (this=0x9e55ad0, fileList=0xbf9f24e4) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/uml.cpp:2213
#18 0x0831fa7e in UMLApp::slotImportClasses (this=0x9e55ad0) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/uml.cpp:2250
#19 0x0832a88d in UMLApp::qt_metacall (this=0x9e55ad0, _c=QMetaObject::InvokeMetaMethod, _id=51, _a=0xbf9f263c)
    at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0_build/umbrello/umbrello/uml.moc:276
#20 0xb6ac12c1 in QMetaObject::activate () from /usr/lib/qt4/libQtCore.so.4
#21 0xb6ac15f1 in QMetaObject::activate () from /usr/lib/qt4/libQtCore.so.4
#22 0xb6c784c2 in QAction::triggered () from /usr/lib/qt4/libQtGui.so.4
#23 0xb6c7978b in QAction::activate () from /usr/lib/qt4/libQtGui.so.4
#24 0xb7088d9a in QMenuPrivate::activateCausedStack () from /usr/lib/qt4/libQtGui.so.4
#25 0xb708f2f9 in QMenuPrivate::activateAction () from /usr/lib/qt4/libQtGui.so.4
#26 0xb70900f6 in QMenu::mouseReleaseEvent () from /usr/lib/qt4/libQtGui.so.4
#27 0xb7a0d526 in KMenu::mouseReleaseEvent () from /usr/lib/libkdeui.so.5
#28 0xb6cd198a in QWidget::event () from /usr/lib/qt4/libQtGui.so.4
#29 0xb7090bb1 in QMenu::event () from /usr/lib/qt4/libQtGui.so.4
#30 0xb6c7e00c in QApplicationPrivate::notify_helper () from /usr/lib/qt4/libQtGui.so.4
#31 0xb6c86552 in QApplication::notify () from /usr/lib/qt4/libQtGui.so.4
#32 0xb79246fe in KApplication::notify () from /usr/lib/libkdeui.so.5
#33 0xb6aae982 in QCoreApplication::notifyInternal () from /usr/lib/qt4/libQtCore.so.4
#34 0xb6c87a34 in QApplicationPrivate::sendMouseEvent () from /usr/lib/qt4/libQtGui.so.4
#35 0xb6ce8fad in QETWidget::translateMouseEvent () from /usr/lib/qt4/libQtGui.so.4
#36 0xb6ce78d5 in QApplication::x11ProcessEvent () from /usr/lib/qt4/libQtGui.so.4
#37 0xb6d0ee12 in x11EventSourceDispatch () from /usr/lib/qt4/libQtGui.so.4
#38 0xb5f88398 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#39 0xb5f8babb in g_main_context_iterate () from /usr/lib/libglib-2.0.so.0
#40 0xb5f8bc49 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#41 0xb6ad6769 in QEventDispatcherGlib::processEvents () from /usr/lib/qt4/libQtCore.so.4
#42 0xb6d0e606 in QGuiEventDispatcherGlib::processEvents () from /usr/lib/qt4/libQtGui.so.4
#43 0xb6aad0bb in QEventLoop::processEvents () from /usr/lib/qt4/libQtCore.so.4
#44 0xb6aad29a in QEventLoop::exec () from /usr/lib/qt4/libQtCore.so.4
#45 0xb6aaf521 in QCoreApplication::exec () from /usr/lib/qt4/libQtCore.so.4
#46 0xb6c7de78 in QApplication::exec () from /usr/lib/qt4/libQtGui.so.4
#47 0x08307185 in main (argc=3, argv=0xbf9f47e4) at /var/tmp/portage/kde-base/umbrello-4.3.0/work/umbrello-4.3.0/umbrello/umbrello/main.cpp:111

Reported using DrKonqi
Comment 1 Ralf Habacker 2011-11-30 09:39:01 UTC
Created attachment 66218 [details]
patch fixing the runtime error

The problem here is that the java importer crashes when a java file is imported from a location outside the regular java package hierachy. 
While finding unknown classes the parser tries to step up in the package hierachy to find the package root, which fails with a runtime error when the path do not fit into the package hierachy. 

Because java package hierachy is very important for the java import I suggest to add a user warning if file pathes of imported files are outside the java package hierachy.
Comment 2 Ralf Habacker 2011-11-30 09:42:14 UTC
Comment on attachment 66218 [details]
patch fixing the runtime error

sorry, this patch belongs to another bug
Comment 3 Ralf Habacker 2011-11-30 14:39:32 UTC
The first issue with the exceeded limits is fixed in r1266700. 

The second issue is caused by a code bug: In IDLImport::parseStmt() there is the following code with the problematic line marked with !!!

if (keyword == "interface") {
[1]
        const QString& name = advance();
        UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Class,
                        name, m_scope[m_scopeIndex], m_comment);
!!!     m_scope[++m_scopeIndex] = m_klass = static_cast<UMLClassifier*>(ns);
        m_klass->setStereotype("CORBAInterface");
        m_klass->setAbstract(m_isAbstract);
        m_isAbstract = false;
        m_comment.clear();
        if (advance() == ";")   // forward declaration
            return true;
[2]

This line is responsible for setting the current parent scope, which. Unfortunally the part between [1] and [2] handles also the interface forward declaration, which mean each forward declaration adds a new parent scope, which let at last m_scope overflow. 

The solution to this problem is to split 

!!!     m_scope[++m_scopeIndex] = m_klass = static_cast<UMLClassifier*>(ns);

into the following part at the original location 

!!!     m_klass = static_cast<UMLClassifier*>(ns);

and the remaining part at [2] where real interfaces are hANDÖED:- 


        if (advance() == ";")   // forward declaration
            return true;


m_scope[++m_scopeIndex] = m_klass = static_cast<UMLClassifier*>(ns);
Comment 4 Ralf Habacker 2011-11-30 14:44:15 UTC
(In reply to comment #3)

> The solution to this problem is to split 
> 
> !!!     m_scope[++m_scopeIndex] = m_klass = static_cast<UMLClassifier*>(ns);
> 
> into the following part at the original location 
> 
> !!!     m_klass = static_cast<UMLClassifier*>(ns);
> 
> and the remaining part at [2] where real interfaces are 

hmmh, submitted by browser accident .... continued ... 

handled. 

        if (advance() == ";")   // forward declaration
            return true;
[2]        m_scope[++m_scopeIndex] = m_klass;

The same belongs to the "valuetype" keyword
Comment 5 Ralf Habacker 2011-11-30 14:53:36 UTC
fixes applied to svn trunk
Comment 6 Ralf Habacker 2013-11-06 17:30:40 UTC
set version-fixed-in from 4.8.0 changelog