Bug 347498 - valgrind reports memory leaks
Summary: valgrind reports memory leaks
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 2.16.1 (KDE Applications 15.04.1)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-10 08:37 UTC by Ralf Habacker
Modified: 2020-10-03 22:35 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.16.1 (KDE Applications 15.04.1)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2015-05-10 08:37:17 UTC
Running umbrello with valgrind reports several memory leaks.


Reproducible: Always

Steps to Reproduce:
1. run umbrello with valgrind


Actual Results:  
There are several memory leaks reported inside umbrello and inside the used libraries.

Expected Results:  
There should be no memory leaks in umbrello code.
Comment 1 Ralf Habacker 2015-05-10 10:43:24 UTC
Git commit fe32a49862d7203f450c51c30025b99fcf80c748 by Ralf Habacker.
Committed on 10/05/2015 at 10:39.
Pushed by habacker into branch 'Applications/15.04'.

Fix memory leak not freeing UMLApp instance.

We use QPointer to avoid access to dangled pointer.

M  +5    -2    umbrello/main.cpp

http://commits.kde.org/umbrello/fe32a49862d7203f450c51c30025b99fcf80c748
Comment 2 Ralf Habacker 2015-05-10 10:43:25 UTC
Git commit cbe2312b8fb7a3e21edb9de99d2f996c07dd12a0 by Ralf Habacker.
Committed on 10/05/2015 at 10:40.
Pushed by habacker into branch 'Applications/15.04'.

Fix memory leaks reported by valgrind in class UMLApp by not deleting class members and not disconnecting signal/slot connections.

Reorder class member list in destructor alphabetical.

M  +12   -5    umbrello/uml.cpp

http://commits.kde.org/umbrello/cbe2312b8fb7a3e21edb9de99d2f996c07dd12a0
Comment 3 Ralf Habacker 2015-05-10 10:43:26 UTC
Git commit 9188fd0dc7b4b07b4043cf02ed14113787c55ba4 by Ralf Habacker.
Committed on 10/05/2015 at 10:40.
Pushed by habacker into branch 'Applications/15.04'.

Fix memory leak in class UMLScene not deleting m_layoutGrid class member.

M  +1    -0    umbrello/umlscene.cpp

http://commits.kde.org/umbrello/9188fd0dc7b4b07b4043cf02ed14113787c55ba4
Comment 4 Ralf Habacker 2015-05-10 10:43:26 UTC
Git commit c765a558338badd29beee430e757921d62b8a4f7 by Ralf Habacker.
Committed on 10/05/2015 at 10:40.
Pushed by habacker into branch 'Applications/15.04'.

Fix memory leak in class UMLView not deleting UMLScene instance.

M  +1    -1    umbrello/umlview.cpp

http://commits.kde.org/umbrello/c765a558338badd29beee430e757921d62b8a4f7
Comment 5 Ralf Habacker 2015-05-10 10:46:55 UTC
Git commit b2c94b0003eec73ad8534ed84aea01936acbc582 by Ralf Habacker.
Committed on 10/05/2015 at 10:41.
Pushed by habacker into branch 'Applications/15.04'.

Fix memory leak in class UMLAppPrivate not deleting class member logWindow.

M  +5    -0    umbrello/umlappprivate.h

http://commits.kde.org/umbrello/b2c94b0003eec73ad8534ed84aea01936acbc582
Comment 6 Ralf Habacker 2015-05-10 10:47:01 UTC
Git commit da87d376a0cad8e12e0ae862af43e4f66b30ed60 by Ralf Habacker.
Committed on 10/05/2015 at 10:41.
Pushed by habacker into branch 'Applications/15.04'.

Fix memory leaks in class UMLDoc by not deleting class members and not disconnecting signal/slot connections.

M  +15   -0    umbrello/umldoc.cpp

http://commits.kde.org/umbrello/da87d376a0cad8e12e0ae862af43e4f66b30ed60
Comment 7 Ralf Habacker 2015-05-10 11:21:07 UTC
Git commit 2cb3559c385a1de73e0b0e36056d32fbfdb7957f by Ralf Habacker.
Committed on 10/05/2015 at 10:57.
Pushed by habacker into branch 'Applications/15.04'.

Fix memory leak in UMLApp::executeCommand() not deleting undo command with disabled undo stack.

M  +1    -0    umbrello/uml.cpp

http://commits.kde.org/umbrello/2cb3559c385a1de73e0b0e36056d32fbfdb7957f
Comment 8 Oliver Kellogg 2020-10-03 20:58:40 UTC
(In reply to Ralf Habacker from comment #1)
> Git commit fe32a49862d7203f450c51c30025b99fcf80c748 by Ralf Habacker.
> Committed on 10/05/2015 at 10:39.
> Pushed by habacker into branch 'Applications/15.04'.
> 
> Fix memory leak not freeing UMLApp instance.
> 
> We use QPointer to avoid access to dangled pointer.
> 
> M  +5    -2    umbrello/main.cpp
> 
> http://commits.kde.org/umbrello/fe32a49862d7203f450c51c30025b99fcf80c748

I experienced the following crash on exiting Umbrello:

Application: Umbrello UML Modeller (umbrello5), signal: Segmentation fault

[KCrash Handler]
#4  0x0000000000471e88 in QListData::size() const (this=0x98) at /usr/include/qt5/QtCore/qlist.h:115
#5  0x00000000004d156e in QtPrivate::indexOf<QPointer<UMLObject>, QPointer<UMLObject> >(QList<QPointer<UMLObject> > const&, QPointer<UMLObject> const&, int) (list=..., u=..., from=0) at /usr/include/qt5/QtCore/qlist.h:1038
#6  0x00000000004d1335 in QList<QPointer<UMLObject> >::indexOf(QPointer<UMLObject> const&, int) const (this=0x98, t=..., from=0) at /usr/include/qt5/QtCore/qlist.h:1026
#7  0x00000000004d0f31 in QList<QPointer<UMLObject> >::removeAll(QPointer<UMLObject> const&) (this=0x98, _t=...) at /usr/include/qt5/QtCore/qlist.h:936
#8  0x00000000004d0e4a in UMLCanvasObject::subordinates() const (this=0x0) at /master-af16785/umbrello/uml1model/umlcanvasobject.h:81
#9  0x000000000060a367 in UMLClassifier::getAttributeList() const (this=0x0) at /master-af16785/umbrello/uml1model/classifier.cpp:439
#10 0x0000000000723b53 in UMLScene::createAutoAttributeAssociations(UMLWidget*) (this=0x2d57b70, widget=0x2d451e0) at /master-af16785/umbrello/umlscene.cpp:2635
#11 0x0000000000691449 in UMLWidget::updateWidget() (this=0x2d451e0) at /master-af16785/umbrello/umlwidgets/umlwidget.cpp:654
#12 0x000000000048ba2c in UMLWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=0x2d451e0, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0x7ffeed6c24b0) at /master-af16785/build/umbrello/libumbrello_autogen/IRKO7FPKWT/moc_umlwidget.cpp:111
#13 0x00007fe97d2bc680 in doActivate<false>(QObject*, int, void**) (sender=0x32ae350, signal_index=3, argv=0x7ffeed6c24b0) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:395
#14 0x000000000048683b in UMLObject::modified() (this=0x32ae350) at /master-af16785/build/umbrello/libumbrello_autogen/P4742RWANA/moc_umlobject.cpp:219
#15 0x000000000062ecf7 in UMLObject::emitModified() (this=0x32ae350) at /master-af16785/umbrello/uml1model/umlobject.cpp:389
#16 0x000000000062efed in UMLObject::setUMLStereotype(UMLStereotype*) (this=0x32ae350, stereo=0x0) at /master-af16785/umbrello/uml1model/umlobject.cpp:518
#17 0x000000000062e27f in UMLObject::~UMLObject() (this=0x32ae350, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/umlobject.cpp:113
#18 0x000000000062ae96 in UMLCanvasObject::~UMLCanvasObject() (this=0x32ae350, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/umlcanvasobject.cpp:45
#19 0x0000000000625c8e in UMLPackage::~UMLPackage() (this=0x32ae350, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/package.cpp:47
#20 0x00000000006086ca in UMLClassifier::~UMLClassifier() (this=0x32ae350, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/classifier.cpp:74
#21 0x00000000006086e6 in UMLClassifier::~UMLClassifier() (this=0x32ae350, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/classifier.cpp:76
#22 0x00007fe97d2afc7e in QObjectPrivate::deleteChildren() (this=0x2d3a4e0) at kernel/qobject.cpp:2104
#23 0x00007fe97d2ba854 in QObject::~QObject() (this=<optimized out>, __in_chrg=<optimized out>) at kernel/qobject.cpp:1082
#24 0x000000000062e3bb in UMLObject::~UMLObject() (this=0x2d53e60, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/umlobject.cpp:110
#25 0x000000000062ae96 in UMLCanvasObject::~UMLCanvasObject() (this=0x2d53e60, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/umlcanvasobject.cpp:45
#26 0x0000000000625c8e in UMLPackage::~UMLPackage() (this=0x2d53e60, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/package.cpp:47
#27 0x000000000061963e in UMLFolder::~UMLFolder() (this=0x2d53e60, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/folder.cpp:48
#28 0x000000000061965a in UMLFolder::~UMLFolder() (this=0x2d53e60, __in_chrg=<optimized out>) at /master-af16785/umbrello/uml1model/folder.cpp:52
#29 0x00000000006f063a in UMLDoc::~UMLDoc() (this=0x2abc280, __in_chrg=<optimized out>) at /master-af16785/umbrello/umldoc.cpp:208
#30 0x00000000006f078e in UMLDoc::~UMLDoc() (this=0x2abc280, __in_chrg=<optimized out>) at /master-af16785/umbrello/umldoc.cpp:216
#31 0x00000000006dda31 in UMLApp::~UMLApp() (this=0x29d3000, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at /master-af16785/umbrello/uml.cpp:262
#32 0x00000000006ddb00 in UMLApp::~UMLApp() (this=0x29d3000, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at /master-af16785/umbrello/uml.cpp:264
#33 0x0000000000471687 in main(int, char**) (argc=2, argv=0x7ffeed6c2da8) at /master-af16785/umbrello/main.cpp:241

AFAICT the critical place is umlobject.cpp:518 UMLObject::setUMLStereotype(0),
    emitModified();

We should not emit the signal during destruction.
Comment 9 Oliver Kellogg 2020-10-03 22:35:26 UTC
Git commit 41b8e258d9ca1bcee82a687ea0d25a5cb56c10c9 by Oliver Kellogg.
Committed on 03/10/2020 at 22:33.
Pushed by okellogg into branch 'master'.

https://bugs.kde.org/show_bug.cgi?id=347498#c8
> I experienced the following crash on exiting Umbrello:
> Application: Umbrello...  (umbrello5), signal: Segmentation fault
> [...]
> AFAICT the critical place is umlobject.cpp ... setUMLStereotype,
>    emitModified();
> We should not emit the signal during destruction.

umbrello/uml.{h,cpp}
- Add public static function shuttingDown() returning bool.
- Add private static variable s_shuttingDown with documentation on why
  this variable is static.
- In UMLApp destructor set s_shuttingDown to true.

- In function setUMLStereotype(UMLStereotype) conditionalize call to
  emitModified() on UMLApp::shuttingDown() returning false.

M  +17   -0    umbrello/uml.cpp
M  +3    -0    umbrello/uml.h
M  +2    -1    umbrello/uml1model/umlobject.cpp

https://invent.kde.org/sdk/umbrello/commit/41b8e258d9ca1bcee82a687ea0d25a5cb56c10c9