Skip to content

ui: avoid crashing when restart command is unavailable#624

Closed
JR-Morton wants to merge 1 commit into
canonical:mainfrom
JR-Morton:fix/restart-missing-proccmdline
Closed

ui: avoid crashing when restart command is unavailable#624
JR-Morton wants to merge 1 commit into
canonical:mainfrom
JR-Morton:fix/restart-missing-proccmdline

Conversation

@JR-Morton
Copy link
Copy Markdown

@JR-Morton JR-Morton commented May 4, 2026

Summary

Fix the GTK Hang dialog so it does not offer "Relaunch this application"
when the report has no ProcCmdline.

The regular crash dialog already has this guard, but the Hang-specific
path did not. If the checkbox was selected, apport later called
UserInterface.restart(), which asserts that ProcCmdline exists.

Notes

Report.add_proc_info() normally sets ProcCmdline, but reports can still
lack it if the field is removed by hooks or if the report was generated
outside the normal collection path. In that case the UI should not offer a
restart.

Changes

  • Only show the GTK Hang relaunch checkbox when ProcCmdline is present.
  • Also require ProcCmdline before setting response.restart.
  • Add a GTK system test covering a Hang report without ProcCmdline.
  • Keep UserInterface.restart()'s assertion unchanged.

Test

  • python3 -m unittest tests.unit.test_ui
  • python3 -m unittest tests.system.test_ui_gtk
  • git diff --check

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.58%. Comparing base (b24ed44) to head (5f699c8).

Files with missing lines Patch % Lines
kde/apport-kde 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #624      +/-   ##
==========================================
+ Coverage   84.54%   84.58%   +0.03%     
==========================================
  Files         104      104              
  Lines       21028    21061      +33     
  Branches     3219     3221       +2     
==========================================
+ Hits        17779    17815      +36     
+ Misses       2809     2805       -4     
- Partials      440      441       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@bdrung bdrung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making restart a no-op, could we change the UI instead to not allow restarting in case ProcCmdline is missing?

@schopin-pro
Copy link
Copy Markdown
Contributor

schopin-pro commented May 5, 2026 via email

@JR-Morton JR-Morton force-pushed the fix/restart-missing-proccmdline branch from cdf3184 to 967b976 Compare May 5, 2026 21:49
Copy link
Copy Markdown
Member

@bdrung bdrung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the same kind of change to kde/apport-kde.

Comment thread gtk/apport-gtk Outdated
self.w("ignore_future_problems").hide()
self.w("relaunch_app").set_active(True)
self.w("relaunch_app").show()
if "ProcCmdline" in self.report:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we extent the UI object with an can_restart method that does this check?

The GTK Hang dialog showed "Relaunch this application" whenever restart was offered, even if the report did not contain ProcCmdline. If selected, this reached UserInterface.restart(), which asserts that ProcCmdline is available.

The regular crash path already checks for ProcCmdline before offering relaunch. Apply the same rule to the Hang path, and keep the same guard when translating the dialog state into response.restart.

Add a GTK system test for a Hang report without ProcCmdline.
@JR-Morton JR-Morton force-pushed the fix/restart-missing-proccmdline branch from 967b976 to 5f699c8 Compare May 6, 2026 22:25
@bdrung
Copy link
Copy Markdown
Member

bdrung commented May 7, 2026

I wasn't aware that we have offer_restart. This can make having can_restart and offer_restart confusing. The UI should only present the restart when we want to offer it plus apport can do that.

@JR-Morton JR-Morton closed this by deleting the head repository May 17, 2026
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.

3 participants