https://bugs.kde.org/show_bug.cgi?id=466062
Bug ID: 466062 Summary: KXMLGUIFactory::removeClient leaks memory when a menu not fully closed Classification: Frameworks and Libraries Product: frameworks-kxmlgui Version: 5.103.0 Platform: Fedora RPMs OS: Linux Status: REPORTED Keywords: testcase Severity: normal Priority: NOR Component: general Assignee: kdelibs-b...@kde.org Reporter: lukasz.wojnilow...@gmail.com Target Milestone: --- Created attachment 156478 --> https://bugs.kde.org/attachment.cgi?id=156478&action=edit Test case for bug #460634 SUMMARY In the attached test case, triggering Edit->Find with a mouse causes a memory leak. Triggering it with a keybord shortcut Ctrl+F doesn't cause a memory leak. The same mechanism is used in Lokalize and eventually causes there a crash. I figured out that the crash happens because QEvent::MouseMove on a menu widget, being closed after click operation, gets converted to QEvent::MouseButtonRelease in QWidgetWindow::handleMouseEvent and is being sent to the main window/menu widget somewhere in the process of deleting menu widget, but reaches the menu widget after its deletinon. It's difficult for me to decide on which side the bug is: Qt, KDE or Lokalize. Qt sends an event to a widget it knows that is in the process of deleting. KDE in KXMLGUIFactory::removeClient uses a delete operator instead of deleteLater method for widgets to be deleted and not checking if there is already any signal in the event queue for them. STEPS TO REPRODUCE 1. Compile the attached test case 2. Execute "valgrind --tool=memcheck myapp" in terminal 3. Click on Edit->Find with mouse (important to do it with a mouse!) OBSERVED RESULT "Invalid write of size 1" in terminal. EXPECTED RESULT No "Invalid write of size 1" in terminal. SOFTWARE/OS VERSIONS Linux/KDE Plasma: Fedora 37 KDE Plasma Version: 5.27.0 KDE Frameworks Version: 5.103.0 Qt Version: 5.15.8 ADDITIONAL INFORMATION -- You are receiving this mail because: You are watching all bug changes.