Bug 134566 - memory protection fault when importing c++ headers
Summary: memory protection fault when importing c++ headers
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-24 00:42 UTC by Rafal Molotkiewicz
Modified: 2013-11-02 23:24 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafal Molotkiewicz 2006-09-24 00:42:14 UTC
Version:           1.5.4 (using KDE KDE 3.5.4)
Installed from:    Gentoo Packages
Compiler:          gcc-3.4.6 and gcc-4.1.1 tried on different machines and gcc versios
OS:                Linux

I have "Use new c++/Java/Ruby generators" disabled.
I can import most headers with no problem at all.
When I try to import any of POCO headers, however, application is killed with Memory Protection Fault. No extensive memory usage can be seen, crash is instant.

POCO can be found here: http://www.appinf.com/poco/
I'll add example crashing header (and example non-crashing one) here if required/requested.
Comment 1 Oliver Kellogg 2006-09-24 16:30:55 UTC
SVN commit 587943 by okellogg:

Importing POCO doesn't crash on the current wavefront but reveals a problem
 with duplicated datatypes (e.g. "const std::string&" appears many times in
 the Datatypes folder) which is fixed by r587941 and this here.
BUG:134566


 M  +11 -7     import_utils.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/import_utils.cpp #587942:587943
@@ -25,6 +25,7 @@
 #include "../umlobject.h"
 #include "../docwindow.h"
 #include "../package.h"
+#include "../folder.h"
 #include "../enum.h"
 #include "../datatype.h"
 #include "../classifier.h"
@@ -119,6 +120,12 @@
                                         QString comment,
                                         QString stereotype) {
     UMLDoc *umldoc = UMLApp::app()->getDocument();
+    UMLFolder *logicalView = umldoc->getRootFolder(Uml::mt_Logical);
+    if (parentPkg == NULL) {
+        // kdDebug() << "Import_Utils::createUMLObject(" << name
+        //     << "): parentPkg is NULL, assuming Logical View" << endl;
+        parentPkg = logicalView;
+    }
     UMLObject * o = umldoc->findUMLObject(name, type, parentPkg);
     bNewUMLObjectWasCreated = false;
     if (o == NULL) {
@@ -135,7 +142,7 @@
         if (origType == NULL) {
             // Still not found. Create the stripped down type.
             if (bPutAtGlobalScope)
-                parentPkg = NULL;
+                parentPkg = logicalView;
             // Find, or create, the scopes.
             QStringList components;
             if (typeName.contains("::")) {
@@ -182,11 +189,8 @@
             // Create the full given type (including adornments.)
             if (isConst)
                 name.prepend("const ");
-            if (bPutAtGlobalScope) {
-                parentPkg = NULL;
-                bPutAtGlobalScope = false;
-            }
-            o = Object_Factory::createUMLObject(Uml::ot_Datatype, name, parentPkg,
+            o = Object_Factory::createUMLObject(Uml::ot_Datatype, name,
+                                                umldoc->getDatatypeFolder(),
                                                 false); //solicitNewName
             UMLDatatype *dt = static_cast<UMLDatatype*>(o);
             UMLClassifier *c = dynamic_cast<UMLClassifier*>(origType);
@@ -236,7 +240,7 @@
                                         bool isStatic /* =false */) {
     Uml::Object_Type ot = owner->getBaseType();
     Uml::Programming_Language pl = UMLApp::app()->getActiveLanguage();
-    if (ot != Uml::ot_Class && pl != Uml::pl_Java) {
+    if (! (ot == Uml::ot_Class || ot == Uml::ot_Interface && pl == Uml::pl_Java)) {
         kdDebug() << "insertAttribute: Don't know what to do with "
         << owner->getName() << " (object type " << ot << ")" << endl;
         return NULL;
Comment 2 Rafal Molotkiewicz 2006-09-24 22:16:24 UTC
In umbrello 1.5.4 there is no folder.h file at all. Should this patch be applied on cvs/svn version? This info would be helpful...
Now the solution just can't work on the program version the bug was submited for, so I'm thinking about re-opening bugreport.
Comment 3 Oliver Kellogg 2006-09-24 23:15:31 UTC
Turns out I was a little quick closing this bug.
On importing poco-1.2.3/Foundation/include/Poco, there is a segfault even
with the wavefront. Reason: Mutual #include between Types.h and Foundation.h.
(Workaround is simple: Just remove the #include "Foundation.h" in Types.h.)
To solve this bug, Umbrello's C++ import would have to respect #ifdef and
implement #define.
Comment 4 Ralf Habacker 2013-08-14 19:47:05 UTC
preprocessor macros has been added to umbrello at Fri Apr 4 00:03:21 2008 +0000 by Jean Vittor  
https://projects.kde.org/projects/kde/kdesdk/umbrello/repository/revisions/2265c6cb6c8c5ce77c5dbf0489dd130c4831f43e