Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11383 closed Bug Report - Crash (fixed)

Closing a screen when using the Qt painter can segfault

Reported by: paulh <mythtv@…> Owned by: paulh
Priority: minor Milestone: 0.26.1
Component: MythTV - User Interface Library Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

This has been observed when closing the volume popup in MythMusic but could affect any screen. To reproduce change to the Qt painter then:-

  1. Change the volume in MythMusic which shows the volume popup dialog.
  2. Immediately press ESCAPE to close the dialog.

What's happening is

  1. The keypressEvent gets passed to MythMusicVolumeDialog::keyPressEvent() which in turn passes it to MythScreenType::keyPressEvent()
  1. MythScreenType::keyPressEvent() then calls MythScreenType::Close() which then calls MythScreenStack::PopScreen?()
  1. Because we are using the Qt painter there is no fade effect or animation to do so the screen gets deleted right away in PopScreen?().
  1. At this point we return to MythMusicVolumeDialog::keyPressEvent() of the now deleted screen where any access to any members is going to segfault which is what happens in this case.

A simple generic fix would be to change in MythScreenStack::PopScreen?()

delete screen;

to

screen->deleteLater();

so the keypressEvent handlers could complete safely before the screen is eventually deleted when control returns to the event loop.

Change History (5)

comment:1 Changed 11 years ago by paulh <mythtv@…>

This has been confirmed to fix the segfault https://github.com/paul-h/mythtv/commit/1b92f4c277

comment:2 Changed 11 years ago by Paul Harrison <mythtv@…>

Resolution: fixed
Status: newclosed

In c713988707d2c795a2a2abeff817d1b187d4b3f6/mythtv:

Fix possible segfault when exiting a screen when using the Qt painter

This changes MythScreenStack::PopScreen?() to call deleteLater() on the
screen rather than immediately deleting it so as to allow any keypressEvent
handlers to complete safely before the screen is deleted when control
returns to the event loop.

Fixes #11383.

comment:3 Changed 11 years ago by Raymond Wagner

Milestone: unknown0.27

comment:4 Changed 11 years ago by Paul Harrison <mythtv@…>

In d1a48313dac5510795250c783bca2fe56ee6d7b1/mythtv:

Fix possible segfault when exiting a screen when using the Qt painter

This changes MythScreenStack::PopScreen?() to call deleteLater() on the
screen rather than immediately deleting it so as to allow any keypressEvent
handlers to complete safely before the screen is deleted when control
returns to the event loop.

Fixes #11383.
(cherry picked from commit c713988707d2c795a2a2abeff817d1b187d4b3f6)

comment:5 Changed 11 years ago by paulh

Milestone: 0.270.26.1
Owner: changed from stuartm to paulh
Note: See TracTickets for help on using tickets.