Skip to content

Fix AttachProcessDialog leak causing DebuggerController ref leak#1062

Open
xusheng6 wants to merge 2 commits intodevfrom
test_fix_attach_dialog_leak
Open

Fix AttachProcessDialog leak causing DebuggerController ref leak#1062
xusheng6 wants to merge 2 commits intodevfrom
test_fix_attach_dialog_leak

Conversation

@xusheng6
Copy link
Copy Markdown
Member

Summary

  • AttachProcessDialog was heap-allocated with new but never freed in the attach action handler (ui/ui.cpp)
  • Since it owns a ProcessListWidget which holds a DbgRef<DebuggerController>, this also caused the controller to leak
  • Added deleteLater() on all exit paths after the dialog is used

Test plan

  • Open a binary, attach to a process via the debugger, then stop debugging and close the file
  • Verify no DebuggerController leak is reported in the leak detector

Fix #1061

🤖 Generated with Claude Code

AttachProcessDialog was heap-allocated but never freed. Since it owns a
ProcessListWidget which holds a DbgRef<DebuggerController>, this also
caused the controller to leak.

Add deleteLater() calls on all exit paths after the dialog is used.

Fix #1061

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@xusheng6 xusheng6 requested a review from plafosse April 10, 2026 01:58
@plafosse
Copy link
Copy Markdown
Member

Why allocate at all?

AttachProcessDialog dialog(context->mainWindow(), controller);
if (dialog.exec() != QDialog::Accepted)
    return;

uint32_t pid = dialog.GetSelectedPid();
if (pid == 0)
    return;

@xusheng6
Copy link
Copy Markdown
Member Author

Why allocate at all?


AttachProcessDialog dialog(context->mainWindow(), controller);

if (dialog.exec() != QDialog::Accepted)

    return;



uint32_t pid = dialog.GetSelectedPid();

if (pid == 0)

    return;

Good point -- let me fix that

Address review feedback: switch from heap allocation with deleteLater()
to stack allocation, which handles cleanup automatically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttachProcessDialog leaks when the user opens it from the menu, not the controls widget

2 participants