Skip to content

memory leak HardwareBreakpoints::cpuContextMenu and friends #744

@sorokin

Description

@sorokin

Leak sanitizer reports these leaks:

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f5c95377d80 in operator new(unsigned long) (/nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib/libasan.so.5+0xedd80)
    #1 0x7f5c7e695267 in HardwareBreakpointsPlugin::HardwareBreakpoints::stackContextMenu() /home/ivan/d/edb-debugger/plugins/HardwareBreakpoints/HardwareBreakpoints.cpp:253
    #2 0x694aac in Debugger::Debugger(QWidget*) /home/ivan/d/edb-debugger/src/Debugger.cpp:485
    #3 0x4e683a in start_debugger /home/ivan/d/edb-debugger/src/main.cpp:96
    #4 0x4e683a in main /home/ivan/d/edb-debugger/src/main.cpp:255

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f5c95377d80 in operator new(unsigned long) (/nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib/libasan.so.5+0xedd80)
    #1 0x7f5c7e69ba38 in HardwareBreakpointsPlugin::HardwareBreakpoints::cpuContextMenu() /home/ivan/d/edb-debugger/plugins/HardwareBreakpoints/HardwareBreakpoints.cpp:324
    #2 0x694aac in Debugger::Debugger(QWidget*) /home/ivan/d/edb-debugger/src/Debugger.cpp:485
    #3 0x4e683a in start_debugger /home/ivan/d/edb-debugger/src/main.cpp:96
    #4 0x4e683a in main /home/ivan/d/edb-debugger/src/main.cpp:255

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f5c95377d80 in operator new(unsigned long) (/nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib/libasan.so.5+0xedd80)
    #1 0x7f5c7e6985d7 in HardwareBreakpointsPlugin::HardwareBreakpoints::dataContextMenu() /home/ivan/d/edb-debugger/plugins/HardwareBreakpoints/HardwareBreakpoints.cpp:288
    #2 0x694aac in Debugger::Debugger(QWidget*) /home/ivan/d/edb-debugger/src/Debugger.cpp:485
    #3 0x4e683a in start_debugger /home/ivan/d/edb-debugger/src/main.cpp:96
    #4 0x4e683a in main /home/ivan/d/edb-debugger/src/main.cpp:255

The lines in the stack trace corresponds to the lines where QMenu is created:

	auto menu = new QMenu(tr("Hardware Breakpoints"));

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions