-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
X11 display error sanitizting #385
base: master
Are you sure you want to change the base?
Conversation
I've never had this issue(cannot duplicate it), so it would be difficult for me to test this as a fix. I use Kdenlive (a QT 5 program) a lot, and routinely use the clipboard to input filenames for render jobs with never a problem |
@lukefromdc me neither, this was solely based on backtraces and comments from @ilya-fedin, and after the work on mate-desktop/mate-panel#1308. I'm not entirely convinced the changes I propose here do help much, but I believe they are still good (given I didn't make any mistake) as they sanitize the code to use the display the code actually wants to trap errors on (although I would think it'll always be the same anyway). See #384 (comment) for some more details. |
@lukefromdc one thing we can verify though is that my changes do not make anything worse, and wait for feedback from @ilya-fedin on whether it solves his issues or not. |
@@ -139,8 +139,9 @@ send_selection_notify (MsdClipboardManager *manager, | |||
notify.property = success ? manager->priv->property : None; | |||
notify.time = manager->priv->time; | |||
|
|||
display = gdk_display_get_default (); | |||
gdk_x11_display_error_trap_push (display); | |||
display = gdk_x11_lookup_xdisplay (manager->priv->display); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not change anything. priv->display
is gdk_display_get_default()
:
mate-settings-daemon/plugins/clipboard/msd-clipboard-manager.c
Lines 979 to 986 in 96e1560
static void | |
msd_clipboard_manager_init (MsdClipboardManager *manager) | |
{ | |
manager->priv = msd_clipboard_manager_get_instance_private (manager); | |
manager->priv->display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said, most of it probably don't change anything as there probably is only one display anyway. Yet, gdk_display_get_default()
's return value can theoretically change over time, so this could not be the same. I don't think it ever really happens in most real situations, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that to happen someone would need to call gdk_display_open
to create new display and close default display. Clipboard code is not doing that... Using GtkInspector
you can get second display, but that won't change default display.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code, the simplest way would be calling gdk_display_manager_set_default_display()
, but that's not something any more likely to happen.
The reason I don't answer so long is I've hit a crash even with that patch, unfortunately. Then I tried to set GDK_SYNCHRONIZE=1 as the output in journalctl suggests and haven't hit a crash yet. I don't know though whether this is due to this variable or I just haven't copy-pasted anything that would trigger the bug. |
OK then this means this patchset is not helpful, which is valuable info nonetheless :) |
OK, given @ilya-fedin's feedback, this patchset is not very interesting, apart from its potential better dealing with multiple displays but as discussed it's unlikely to ever actually matter anyway. @muktupavels if you're willing to review this a tad deeper I'd be happy to undo any change you deem unneeded (like the default display we were discussing). Otherwise, I'll just abandon this PR which doesn't fix what it vaguely hoped to. |
Leave only change that makes sure push is always followed by pop. |
96e1560
to
ab48cca
Compare
@muktupavels here we go. FWIW cursory looking at this file there are actually numerous potentially failing X calls unchecked, so maybe this should be dealt with as well? |
Any example where you think error traps should be added? |
@muktupavels As said somewhere before I'm not too knowledgeable about X11 APIs, but I was thinking about several |
Check when/why function can fail... For
I would expect that |
Literally any X call that operates on the |
@muktupavels yeah OK, the ones purely on the internal window could be deemed safe (we'd likely have other issues if it wasn't), if it doesn't include BadAlloc (and even then, GLib aborting on memory error probably suggests BadAlloc might often not be out primary concern). But as @ilya-fedin said, whenever there's something we don't manage ourselves, we have no way to know whether it's (still) valid, and that seems to apply to the 2 @ilya-fedin BTW if you finally can reproduce your issue, you could try guarding pretty much every call with a pair of |
This may or may not fix #384.