After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 763689 - Fix cancelled async calls usage
Fix cancelled async calls usage
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: plugins
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2016-03-15 14:07 UTC by Bastien Nocera
Modified: 2016-03-16 11:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
housekeeping: Don't print warning on call cancellation (1.12 KB, patch)
2016-03-15 14:07 UTC, Bastien Nocera
committed Details | Review
housekeeping: Fix checking for cancellation (1.51 KB, patch)
2016-03-15 14:07 UTC, Bastien Nocera
committed Details | Review
sharing: Don't print warning on call cancellation (1.04 KB, patch)
2016-03-15 14:07 UTC, Bastien Nocera
committed Details | Review
media-keys: Fix screensaver not locking in some cases (1.55 KB, patch)
2016-03-15 14:07 UTC, Bastien Nocera
accepted-commit_now Details | Review
media-keys: Don't print warning on call cancellation (4.09 KB, patch)
2016-03-15 14:07 UTC, Bastien Nocera
committed Details | Review
media-keys: Fix checking for cancellation (1.50 KB, patch)
2016-03-15 14:07 UTC, Bastien Nocera
committed Details | Review
media-keys: Fix possible crash in MPRIS support (1.60 KB, patch)
2016-03-15 14:07 UTC, Bastien Nocera
committed Details | Review
datetime: Fix possible user-after-free when calls are cancelled (4.35 KB, patch)
2016-03-15 14:17 UTC, Bastien Nocera
accepted-commit_now Details | Review
datetime: Fix possible use-after-free when calls are cancelled (4.35 KB, patch)
2016-03-15 15:33 UTC, Bastien Nocera
committed Details | Review
media-keys: Fix screen lock call not being cancelled (1.58 KB, patch)
2016-03-15 15:33 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2016-03-15 14:07:19 UTC
Mostly about printing warnings, but there are at least 2 real bugs fixed as well.
Comment 1 Bastien Nocera 2016-03-15 14:07:22 UTC
Created attachment 323987 [details] [review]
housekeeping: Don't print warning on call cancellation
Comment 2 Bastien Nocera 2016-03-15 14:07:27 UTC
Created attachment 323988 [details] [review]
housekeeping: Fix checking for cancellation

We really don't need to call g_cancellable_is_cancelled() when we could
just check the error code we get back.
Comment 3 Bastien Nocera 2016-03-15 14:07:32 UTC
Created attachment 323989 [details] [review]
sharing: Don't print warning on call cancellation
Comment 4 Bastien Nocera 2016-03-15 14:07:37 UTC
Created attachment 323990 [details] [review]
media-keys: Fix screensaver not locking in some cases

If there was an XRandR call at the same time as we asked to lock the
screen, it's possible that the screen lock would have got cancelled
when it shouldn't.
Comment 5 Bastien Nocera 2016-03-15 14:07:41 UTC
Created attachment 323991 [details] [review]
media-keys: Don't print warning on call cancellation
Comment 6 Bastien Nocera 2016-03-15 14:07:46 UTC
Created attachment 323992 [details] [review]
media-keys: Fix checking for cancellation

We really don't need to call g_cancellable_is_cancelled() when we
could just check the error code we get back.
Comment 7 Bastien Nocera 2016-03-15 14:07:51 UTC
Created attachment 323993 [details] [review]
media-keys: Fix possible crash in MPRIS support

If the D-Bus proxy creation was cancelled, we might have a
use-after-free problem here.
Comment 8 Bastien Nocera 2016-03-15 14:17:16 UTC
Created attachment 323994 [details] [review]
datetime: Fix possible user-after-free when calls are cancelled

1) Don't use the possibly dangling user_data when the calls might
   have been cancelled
2) Don't print warnings when calls were cancelled
3) Don't print criticals for run-time warnings
Comment 9 Rui Matos 2016-03-15 15:10:00 UTC
Review of attachment 323987 [details] [review]:

++
Comment 10 Rui Matos 2016-03-15 15:10:06 UTC
Review of attachment 323988 [details] [review]:

++
Comment 11 Rui Matos 2016-03-15 15:10:42 UTC
Review of attachment 323989 [details] [review]:

++
Comment 12 Rui Matos 2016-03-15 15:12:35 UTC
Review of attachment 323991 [details] [review]:

++
Comment 13 Rui Matos 2016-03-15 15:12:52 UTC
Review of attachment 323992 [details] [review]:

++
Comment 14 Rui Matos 2016-03-15 15:13:50 UTC
Review of attachment 323993 [details] [review]:

right
Comment 15 Rui Matos 2016-03-15 15:27:21 UTC
Review of attachment 323990 [details] [review]:

I don't think what you describe is possible since ->cancellable is only cancelled on plugin stop and finalizing a cancellable as in on_xrandr_action_call_finished() doesn't cancel it.

What could happen though is ->cancellable being NULL on do_lock_screen() and thus we'd never be able to cancel it.

tl;dr the code is fine but the commit message needs to be changed :-)
Comment 16 Bastien Nocera 2016-03-15 15:33:25 UTC
Created attachment 324007 [details] [review]
datetime: Fix possible use-after-free when calls are cancelled

1) Don't use the possibly dangling user_data when the calls might
   have been cancelled
2) Don't print warnings when calls were cancelled
3) Don't print criticals for run-time warnings
Comment 17 Bastien Nocera 2016-03-15 15:33:43 UTC
Created attachment 324008 [details] [review]
media-keys: Fix screen lock call not being cancelled

Because we used the wrong cancellable, it was possible for it not to
exist and the call not being cancelled. As we only used the return value
from the call, this shouldn't cause any crashes.
Comment 18 Rui Matos 2016-03-15 15:35:50 UTC
Review of attachment 323994 [details] [review]:

right
Comment 19 Bastien Nocera 2016-03-15 23:38:24 UTC
Comment on attachment 324007 [details] [review]
datetime: Fix possible use-after-free when calls are cancelled

Moving the patch status from attachment 323994 [details] [review]
Comment 20 Bastien Nocera 2016-03-15 23:38:52 UTC
Comment on attachment 323994 [details] [review]
datetime: Fix possible user-after-free when calls are cancelled

Typo in the commit subject
Comment 21 Bastien Nocera 2016-03-15 23:39:29 UTC
Comment on attachment 324008 [details] [review]
media-keys: Fix screen lock call not being cancelled

Moving patch status from attachment 323990 [details] [review]
Comment 22 Bastien Nocera 2016-03-15 23:40:07 UTC
Comment on attachment 323990 [details] [review]
media-keys: Fix screensaver not locking in some cases

Newer version addresses comment 15
Comment 23 Bastien Nocera 2016-03-16 11:17:13 UTC
Attachment 323987 [details] pushed as fc0e8b6 - housekeeping: Don't print warning on call cancellation
Attachment 323988 [details] pushed as 97a95f0 - housekeeping: Fix checking for cancellation
Attachment 323989 [details] pushed as 86512f6 - sharing: Don't print warning on call cancellation
Attachment 323991 [details] pushed as 86cbfda - media-keys: Don't print warning on call cancellation
Attachment 323992 [details] pushed as 5147e6b - media-keys: Fix checking for cancellation
Attachment 323993 [details] pushed as 645aa76 - media-keys: Fix possible crash in MPRIS support
Attachment 324007 [details] pushed as 15e628d - datetime: Fix possible use-after-free when calls are cancelled
Attachment 324008 [details] pushed as 214145c - media-keys: Fix screen lock call not being cancelled