-
-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memory leak HardwareBreakpoints::cpuContextMenu and friends #744
Comments
I suppose for the purpose of cleanliness, the best way is to save the menu as member But OTOH, does there exist a scenario when there'll be more than one call to |
This approach make it difficult to find real leaks. When you have 1000 false positives and you got one real one it is much more difficult to notice than when you have 0 and you got one. |
I looked at what qactions have shortcuts and apparently there is only one such action: Assemble (Space). I guess I can just introduce a new function something like IPlugin::globalShortcuts to be used in finishPluginSetup. This will limit usages of cpuContextMenu and friends only to the places where real menu need to be created. |
Thanks, I'll check into this |
I think probably the "correct" solution would be for something in Debugger.cpp to take ownership of these |
The issue was about leaks reported by leak sanitizer: Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e695267 in HardwareBreakpointsPlugin::HardwareBreakpoints::stackContextMenu() HardwareBreakpoints.cpp:253 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e69ba38 in HardwareBreakpointsPlugin::HardwareBreakpoints::cpuContextMenu() HardwareBreakpoints.cpp:324 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e6985d7 in HardwareBreakpointsPlugin::HardwareBreakpoints::dataContextMenu() HardwareBreakpoints.cpp:288 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 The most idiomatic way to fix the issue was to assign a parent to the submenus created in these functions. Unfortunately there is no suitable parent available in these functions. This commit fixes the issue in the most straight-forward way possible: it just adds QMenu* parent parameter to the functions * IPlugin::cpuContextMenu * IPlugin::registerContextMenu * IPlugin::stackContextMenu * IPlugin::dataContextMenu This allows plugins to set proper parent to all submenus they choose to create in order for them to be properly destroyed when root menu is destroyed. This commit also sets parents to the QActions that are created in these functions so they are timedly destroyed. As a possible follow-up these QActions can be created once in plugin constructor and not everytime the menu is created.
The issue was about leaks reported by leak sanitizer: Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e695267 in HardwareBreakpointsPlugin::HardwareBreakpoints::stackContextMenu() HardwareBreakpoints.cpp:253 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e69ba38 in HardwareBreakpointsPlugin::HardwareBreakpoints::cpuContextMenu() HardwareBreakpoints.cpp:324 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e6985d7 in HardwareBreakpointsPlugin::HardwareBreakpoints::dataContextMenu() HardwareBreakpoints.cpp:288 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 The most idiomatic way to fix the issue was to assign a parent to the submenus created in these functions. Unfortunately there is no suitable parent available in these functions. This commit fixes the issue in the most straight-forward way possible: it just adds QMenu* parent parameter to the functions * IPlugin::cpuContextMenu * IPlugin::registerContextMenu * IPlugin::stackContextMenu * IPlugin::dataContextMenu This allows plugins to set proper parent to all submenus they choose to create in order for them to be properly destroyed when root menu is destroyed. This commit also sets parents to the QActions that are created in these functions so they are timedly destroyed. As a possible follow-up these QActions can be created once in plugin constructor and not everytime the menu is created.
The issue was about leaks reported by leak sanitizer: Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e695267 in HardwareBreakpointsPlugin::HardwareBreakpoints::stackContextMenu() HardwareBreakpoints.cpp:253 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e69ba38 in HardwareBreakpointsPlugin::HardwareBreakpoints::cpuContextMenu() HardwareBreakpoints.cpp:324 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f5c95377d80 in operator new(unsigned long) eteran#1 0x7f5c7e6985d7 in HardwareBreakpointsPlugin::HardwareBreakpoints::dataContextMenu() HardwareBreakpoints.cpp:288 eteran#2 0x694aac in Debugger::Debugger(QWidget*) Debugger.cpp:485 eteran#3 0x4e683a in start_debugger main.cpp:96 eteran#4 0x4e683a in main main.cpp:255 The most idiomatic way to fix the issue was to assign a parent to the submenus created in these functions. Unfortunately there is no suitable parent available in these functions. This commit fixes the issue in the most straight-forward way possible: it just adds QMenu* parent parameter to the functions * IPlugin::cpuContextMenu * IPlugin::registerContextMenu * IPlugin::stackContextMenu * IPlugin::dataContextMenu This allows plugins to set proper parent to all submenus they choose to create in order for them to be properly destroyed when root menu is destroyed. This commit also sets parents to the QActions that are created in these functions so they are timedly destroyed. As a possible follow-up these QActions can be created once in plugin constructor and not everytime the menu is created.
Leak sanitizer reports these leaks:
The lines in the stack trace corresponds to the lines where QMenu is created:
Notice that QMenu is created without a parent. At first I thought to fix the problem by passing QWidget* parent to cpuContextMenu and this is fine for usages in addPluginContextMenu. But I stuck at the usage in finishPluginSetup.
What do you think is the best way to fix the problem?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: