Bug 110400 - C++ import crash on "template<>"
Summary: C++ import crash on "template<>"
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-08 17:35 UTC by Alan Ezust
Modified: 2005-11-04 11:23 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 Alan Ezust 2005-08-08 17:35:42 UTC
Version:           1.4.89 (using KDE KDE 3.4.1)
Installed from:    Debian testing/unstable Packages
OS:                Linux

I tried importing qt4's qwidget.h into umbrello.
I know it's big and has lots of other includes, so it's tough to figure out exactly what is causing the crash, but I thought I'd attach the backtrace for now and if I can narrow it down, I will attach something else.


[ezust@lazarus] /home/ezust> cat umbrello-dump.txt
Using host libthread_db library "/lib/tls/libthread_db.so.1".
`system-supplied DSO at 0xffffe000' has disappeared; keeping its symbols.
[Thread debugging using libthread_db enabled]
[New Thread -1231142784 (LWP 18363)]
[KCrash handler]
#3  0xb73c3f1e in QGList::QGList () from /usr/lib/libqt-mt.so.3
#4  0x0823c914 in CppTree2Uml::parseTemplateDeclaration (this=0xbfffcc50,
    ast=0x88d2558) at qptrlist.h:69
#5  0x0824a56c in TreeParser::parseDeclaration (this=0xbfffcc50,
    declaration=0x88d2558) at tree_parser.cpp:77
#6  0x0824a483 in TreeParser::parseTranslationUnit (this=0xbfffcc50,
    translationUnit=0x8645cb0) at qptrlist.h:174
#7  0x0823b8d8 in CppTree2Uml::parseTranslationUnit (this=0xbfffcc50, ast=0x4c)
    at cpptree2uml.cpp:57
#8  0x08126aef in ClassImport::feedTheModel (this=0x847bab8, fileName=
      {static null = {static null = <same as static member of an already seen type>, d = 0x83eb070, static shared_null = 0x83eb070}, d = 0x8617a90, static shared_null = 0x83eb070}) at classimport.cpp:335
#9  0x0812728d in ClassImport::importCPP (this=0x847bab8, headerFileList=
        {<QValueList<QString>> = {sh = 0x86fcea0}, <No data fields>})
    at classimport.cpp:381
#10 0x08193988 in UMLApp::slotImportClasses (this=0x84762b8) at qshared.h:49
#11 0x08194c2d in UMLApp::qt_invoke (this=0x84762b8, _id=114, _o=0xbfffd040)
    at uml.moc:290
#12 0xb710c71c in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#13 0xb710c544 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#14 0xb79dc89b in KAction::activated () from /usr/lib/libkdeui.so.4
#15 0xb79dc00a in KAction::slotActivated () from /usr/lib/libkdeui.so.4
#16 0xb79dc139 in KAction::slotPopupActivated () from /usr/lib/libkdeui.so.4
#17 0xb79dcb91 in KAction::qt_invoke () from /usr/lib/libkdeui.so.4
#18 0xb710c71c in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#19 0xb744b62a in QSignal::signal () from /usr/lib/libqt-mt.so.3
#20 0xb712691d in QSignal::activate () from /usr/lib/libqt-mt.so.3
#21 0xb72140d9 in QPopupMenu::mouseReleaseEvent () from /usr/lib/libqt-mt.so.3
#22 0xb79ca0d1 in KPopupMenu::mouseReleaseEvent () from /usr/lib/libkdeui.so.4
#23 0xb7142b37 in QWidget::event () from /usr/lib/libqt-mt.so.3
#24 0xb70afe1f in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#25 0xb70af514 in QApplication::notify () from /usr/lib/libqt-mt.so.3
#26 0xb76ffac5 in KApplication::notify () from /usr/lib/libkdecore.so.4
#27 0xb70441a1 in QETWidget::translateMouseEvent () from /usr/lib/libqt-mt.so.3
#28 0xb704223e in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#29 0xb7059254 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#30 0xb70c21d8 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#31 0xb70c2088 in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#32 0xb70b0071 in QApplication::exec () from /usr/lib/libqt-mt.so.3
#33 0x08166064 in main (argc=76, argv=0x4c) at main.cpp:113
Comment 1 Oliver Kellogg 2005-10-17 19:40:51 UTC
Could you attach the problematic file (stripped down if possible) ?
Comment 2 Chris Burghart 2005-11-04 00:27:47 UTC
This looks like the same bug I'm seeing when trying to import a header which contains a template specialization.  Umbrello will crash importing this simple (and legal) C++ fragment (condensed from the Boost library header /usr/include/boost/shared_ptr.hpp):

-------------------------------------------------
template<class T> struct shared_ptr_traits
{
    typedef T & reference;
};

template<> struct shared_ptr_traits<void>
{
    typedef void reference;
};
-------------------------------------------------

Umbrello's class parser just doesn't like "template<>", which opens a parameterless template specialization.  See Stroustrup's "The C++ Programming Language", 3rd edition, section 13.5 for details on template specialization.
Comment 3 Oliver Kellogg 2005-11-04 11:16:31 UTC
Thanks for clarifying.
Comment 4 Oliver Kellogg 2005-11-04 11:23:48 UTC
SVN commit 477565 by okellogg:

BUG:110400 - Skip parsing of empty template.
Thanks to Chris Burghart <burghart_AT_ucar.edu> for detailing the problem.


 M  +3 -2      ChangeLog  
 M  +2 -0      umbrello/classparser/cpptree2uml.cpp  
 M  +2 -1      umbrello/classparser/parser.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #477564:477565
@@ -6,13 +6,14 @@
 * Externalization of folders (i.e. submodel files)
 * Change interface into class and vice versa (if abstract and no attributes)
 * Image export via command line
+* All diagram objects can be resized
 * Automatic Diagram Layout (67059, not yet closed)
 
 * Bugs fixed / wishes implemented (see http://bugs.kde.org)
  57588  57672  58809  66461  67120  67719  72016  79433  87252  88117
  97162  98368 101550 105564 107405 108223 109591 109636 110073 110216
-110231 110379 110843 111088 111470 111502 111759 111768 112017 112292
-112293 112333 112531 112552 112936 112991 112992 114892
+110231 110379 110400 110843 111088 111470 111502 111759 111768 112017
+112292 112293 112333 112531 112552 112936 112991 112992 114892
 
 Version 1.4.2 (maintenance release)
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/classparser/cpptree2uml.cpp #477564:477565
@@ -170,6 +170,8 @@
 void CppTree2Uml::parseTemplateDeclaration( TemplateDeclarationAST* ast )
 {
     TemplateParameterListAST* parmListAST = ast->templateParameterList();
+    if (parmListAST == NULL)
+        return;
     QPtrList<TemplateParameterAST> parmList = parmListAST->templateParameterList();
     for (QPtrListIterator<TemplateParameterAST> it(parmList); it.current(); ++it) {
         // The template is either a typeParameter or a typeValueParameter.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/classparser/parser.cpp #477564:477565
@@ -927,7 +927,8 @@
     TemplateParameterListAST::Node params;
     if( lex->lookAhead(0) == '<' ){
 	lex->nextToken();
-	parseTemplateParameterList( params );
+	if (lex->lookAhead(0) != '>')
+	    parseTemplateParameterList( params );
 
 	ADVANCE( '>', ">" );
     }