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 765996 - Frequently hotplugging a Wacom device causes g-s-d segfault
Frequently hotplugging a Wacom device causes g-s-d segfault
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: wacom
3.14.x
Other Linux
: Normal critical
: ---
Assigned To: Carlos Garnacho
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2016-05-04 17:38 UTC by Ping Cheng
Modified: 2016-08-22 18:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
g-s-d segfault gdb log (4.31 KB, text/plain)
2016-05-04 17:38 UTC, Ping Cheng
  Details
Backtrace with GNOME 3.20 (10.01 KB, text/x-log)
2016-06-03 21:20 UTC, Jason Gerecke
  Details
Script to trigger segfault (186 bytes, application/x-shellscript)
2016-06-03 21:26 UTC, Jason Gerecke
  Details
Fix for the crash bug (2.70 KB, patch)
2016-07-06 23:24 UTC, Jason Gerecke
committed Details | Review
Bonus memory leak fixes (3.98 KB, patch)
2016-07-06 23:25 UTC, Jason Gerecke
committed Details | Review

Description Ping Cheng 2016-05-04 17:38:25 UTC
Created attachment 327309 [details]
g-s-d segfault gdb log

When frequently connecting/disconnecting a Wacom USB tablet, g-s-d resets a running window session to login prompt. A gdb tracelog shows the issue was caused by a NULL return value from open_device (device).

gdb output is attached.
Comment 1 Bastien Nocera 2016-05-06 15:16:32 UTC
Is this really with GNOME 3.14? Which distribution ships that? Does this happen with newer versions as well?
Comment 2 Ping Cheng 2016-05-07 19:15:34 UTC
The testing was on the latest CentOS 7. "gnome-session --version" on the system tells me it's 3.14. The issue does not always bring window back to login prompt. But, the segfault is reproducible. Use a script to repeatedly load/unload wacom kernel driver is an easier way to trig the issue.
Comment 3 Bastien Nocera 2016-05-09 09:04:22 UTC
It might also happen with newer versions.
Comment 4 Jason Gerecke 2016-06-03 21:20:06 UTC
Created attachment 329094 [details]
Backtrace with GNOME 3.20

This issue is definitely still present in newer releases as well. See the attached backtrace from my Arch Linux box which has gnome-settings-daemon 3.20.1-1 installed.
Comment 5 Jason Gerecke 2016-06-03 21:26:28 UTC
Created attachment 329095 [details]
Script to trigger segfault

The attached script can be used in debugging this issue to trigger the segfault on a machine which has a Wacom tablet connected. All it does repeatedly load and unload the 'wacom' kernel module (so you'll probably need to run it as root) with a small random delay between each step. Triggering the segfault may take anywhere from a few seconds to a few minutes depending on your luck.
Comment 6 Bastien Nocera 2016-06-04 01:35:15 UTC
Can you test with the patch from https://bugzilla.gnome.org/show_bug.cgi?id=766726 ?
Comment 7 Jason Gerecke 2016-06-06 22:19:58 UTC
Looks like that patch does stop the segfaults, though I do see that g-s-d still occasionally terminates (much less than before) due to various G_LOG_LEVEL_ERROR messages. See the following distinct backtraces:

[Backtrace 1]

  • #0 _g_log_abort
    at gmessages.c line 325
  • #1 g_logv
    at gmessages.c line 1080
  • #2 g_log
    at gmessages.c line 1119
  • #3 ??
    from /usr/lib/libgdk-3.so.0
  • #4 ??
    from /usr/lib/libgdk-3.so.0
  • #5 _XError
    from /usr/lib/libX11.so.6
  • #6 ??
    from /usr/lib/libX11.so.6
  • #7 ??
    from /usr/lib/libX11.so.6
  • #8 _XReply
    from /usr/lib/libX11.so.6
  • #9 XSync
    from /usr/lib/libX11.so.6
  • #10 xdevice_get_last_tool_id
    at gsd-input-helper.c line 265
  • #11 setup_property_notify
    at gsd-wacom-device.c line 440
  • #12 gsd_wacom_device_constructor
    at gsd-wacom-device.c line 1511
  • #13 g_object_new_with_custom_constructor
    at gobject.c line 1699
  • #14 g_object_new_internal
    at gobject.c line 1779
  • #15 g_object_new_valist
    at gobject.c line 2040
  • #16 g_object_new
    at gobject.c line 1624
  • #17 gsd_wacom_device_new
    at gsd-wacom-device.c line 1669
  • #18 gsd_wacom_manager_add_gdk_device
    at gsd-wacom-manager.c line 1060
  • #19 device_added_cb
    at gsd-wacom-manager.c line 1134
  • #20 g_closure_invoke
    at gclosure.c line 804
  • #21 signal_emit_unlocked_R
    at gsignal.c line 3629
  • #22 g_signal_emit_valist
    at gsignal.c line 3385
  • #23 g_signal_emit_by_name
    at gsignal.c line 3481
  • #24 add_device
    at gsd-device-manager-x11.c line 122
  • #25 g_closure_invoke
    at gclosure.c line 804
  • #26 signal_emit_unlocked_R
    at gsignal.c line 3629
  • #27 g_signal_emit_valist
    at gsignal.c line 3385
  • #28 g_signal_emit_by_name
    at gsignal.c line 3481
  • #29 ??
    from /usr/lib/libgdk-3.so.0
  • #30 ??
    from /usr/lib/libgdk-3.so.0
  • #31 ??
    from /usr/lib/libgdk-3.so.0
  • #32 ??
    from /usr/lib/libgdk-3.so.0
  • #33 gdk_display_get_event
    from /usr/lib/libgdk-3.so.0
  • #34 ??
    from /usr/lib/libgdk-3.so.0
  • #35 g_main_dispatch
    at gmain.c line 3154
  • #36 g_main_context_dispatch
    at gmain.c line 3769
  • #37 g_main_context_iterate
    at gmain.c line 3840
  • #38 g_main_loop_run
    at gmain.c line 4034
  • #39 gtk_main
    from /usr/lib/libgtk-3.so.0
  • #40 main
    at main.c line 434
  • #0 _g_log_abort
    at gmessages.c line 325
  • #1 g_logv
    at gmessages.c line 1080
  • #2 g_log
    at gmessages.c line 1119
  • #3 ??
    from /usr/lib/libgdk-3.so.0
  • #4 ??
    from /usr/lib/libgdk-3.so.0
  • #5 _XError
    from /usr/lib/libX11.so.6
  • #6 ??
    from /usr/lib/libX11.so.6
  • #7 _XReply
    from /usr/lib/libX11.so.6
  • #8 XIQueryDevice
    from /usr/lib/libXi.so.6
  • #9 xdevice_get_dimensions
    at gsd-input-helper.c line 395
  • #10 create_device
    at gsd-device-manager-x11.c line 81
  • #11 add_device
    at gsd-device-manager-x11.c line 120
  • #12 g_closure_invoke
    at gclosure.c line 804
  • #13 signal_emit_unlocked_R
    at gsignal.c line 3629
  • #14 g_signal_emit_valist
    at gsignal.c line 3385
  • #15 g_signal_emit_by_name
    at gsignal.c line 3481
  • #16 ??
    from /usr/lib/libgdk-3.so.0
  • #17 ??
    from /usr/lib/libgdk-3.so.0
  • #18 ??
    from /usr/lib/libgdk-3.so.0
  • #19 ??
    from /usr/lib/libgdk-3.so.0
  • #20 gdk_display_get_event
    from /usr/lib/libgdk-3.so.0
  • #21 ??
    from /usr/lib/libgdk-3.so.0
  • #22 g_main_dispatch
    at gmain.c line 3154
  • #23 g_main_context_dispatch
    at gmain.c line 3769
  • #24 g_main_context_iterate
    at gmain.c line 3840
  • #25 g_main_loop_run
    at gmain.c line 4034
  • #26 gtk_main
    from /usr/lib/libgtk-3.so.0
  • #27 main
    at main.c line 434
  • #0 _g_log_abort
    at gmessages.c line 325
  • #1 g_logv
    at gmessages.c line 1080
  • #2 g_log
    at gmessages.c line 1119
  • #3 set_absolute
    at gsd-wacom-manager.c line 386
  • #4 set_wacom_settings
    at gsd-wacom-manager.c line 848
  • #5 gsd_wacom_manager_add_gdk_device
    at gsd-wacom-manager.c line 1108
  • #6 device_changed_cb
    at gsd-wacom-manager.c line 1155
  • #7 g_cclosure_marshal_VOID__OBJECTv
    at gmarshal.c line 2102
  • #8 _g_closure_invoke_va
    at gclosure.c line 867
  • #9 g_signal_emit_valist
    at gsignal.c line 3294
  • #10 g_signal_emit_by_name
    at gsignal.c line 3481
  • #11 add_device
    at gsd-device-manager-x11.c line 118
  • #12 g_closure_invoke
    at gclosure.c line 804
  • #13 signal_emit_unlocked_R
    at gsignal.c line 3629
  • #14 g_signal_emit_valist
    at gsignal.c line 3385
  • #15 g_signal_emit_by_name
    at gsignal.c line 3481
  • #16 ??
    from /usr/lib/libgdk-3.so.0
  • #17 ??
    from /usr/lib/libgdk-3.so.0
  • #18 ??
    from /usr/lib/libgdk-3.so.0
  • #19 ??
    from /usr/lib/libgdk-3.so.0
  • #20 gdk_display_get_event
    from /usr/lib/libgdk-3.so.0
  • #21 ??
    from /usr/lib/libgdk-3.so.0
  • #22 g_main_dispatch
    at gmain.c line 3154
  • #23 g_main_context_dispatch
    at gmain.c line 3769
  • #24 g_main_context_iterate
    at gmain.c line 3840
  • #25 g_main_loop_run
    at gmain.c line 4034
  • #26 gtk_main
    from /usr/lib/libgtk-3.so.0
  • #27 main
    at main.c line 434
  • #0 _g_log_abort
    at gmessages.c line 325
  • #1 g_logv
    at gmessages.c line 1080
  • #2 g_log
    at gmessages.c line 1119
  • #3 ??
    from /usr/lib/libgdk-3.so.0
  • #4 ??
    from /usr/lib/libgdk-3.so.0
  • #5 _XError
    from /usr/lib/libX11.so.6
  • #6 ??
    from /usr/lib/libX11.so.6
  • #7 ??
    from /usr/lib/libX11.so.6
  • #8 _XReply
    from /usr/lib/libX11.so.6
  • #9 XSync
    from /usr/lib/libX11.so.6
  • #10 xdevice_get_last_tool_id
    at gsd-input-helper.c line 265
  • #11 setup_property_notify
    at gsd-wacom-device.c line 440
  • #12 gsd_wacom_device_constructor
    at gsd-wacom-device.c line 1511
  • #13 g_object_new_with_custom_constructor
    at gobject.c line 1699
  • #14 g_object_new_internal
    at gobject.c line 1779
  • #15 g_object_new_valist
    at gobject.c line 2040
  • #16 g_object_new
    at gobject.c line 1624
  • #17 gsd_wacom_device_new
    at gsd-wacom-device.c line 1669
  • #18 gsd_wacom_manager_add_gdk_device
    at gsd-wacom-manager.c line 1060
  • #19 device_changed_cb
    at gsd-wacom-manager.c line 1155
  • #20 g_cclosure_marshal_VOID__OBJECTv
    at gmarshal.c line 2102
  • #21 _g_closure_invoke_va
    at gclosure.c line 867
  • #22 g_signal_emit_valist
    at gsignal.c line 3294
  • #23 g_signal_emit_by_name
    at gsignal.c line 3481
  • #24 add_device
    at gsd-device-manager-x11.c line 118
  • #25 g_closure_invoke
    at gclosure.c line 804
  • #26 signal_emit_unlocked_R
    at gsignal.c line 3629
  • #27 g_signal_emit_valist
    at gsignal.c line 3385
  • #28 g_signal_emit_by_name
    at gsignal.c line 3481
  • #29 ??
    from /usr/lib/libgdk-3.so.0
  • #30 ??
    from /usr/lib/libgdk-3.so.0
  • #31 ??
    from /usr/lib/libgdk-3.so.0
  • #32 ??
    from /usr/lib/libgdk-3.so.0
  • #33 gdk_display_get_event
    from /usr/lib/libgdk-3.so.0
  • #34 ??
    from /usr/lib/libgdk-3.so.0
  • #35 g_main_dispatch
    at gmain.c line 3154
  • #36 g_main_context_dispatch
    at gmain.c line 3769
  • #37 g_main_context_iterate
    at gmain.c line 3840
  • #38 g_main_loop_run
    at gmain.c line 4034
  • #39 gtk_main
    from /usr/lib/libgtk-3.so.0
  • #40 main
    at main.c line 434

Comment 8 Jason Gerecke 2016-06-22 20:48:02 UTC
Ping
Comment 9 Bastien Nocera 2016-06-23 12:18:29 UTC
(In reply to Jason Gerecke from comment #8)
> Ping

This isn't useful. A patch would be useful. Everybody's busy.

Seeing as the crash happens when we call gdk_display_sync(), it looks like there's some X calls that aren't wrapped by trap_push()/pop() and that the backtraces were gathered without running X calls synchronously.

Run gnome-settings-daemon with GDK_SYNCHRONIZE=1 and reproduce the problem. The assertion (or crashers) should happen when the X calls actually fail, not the next time we look at the X loop.
Comment 10 Jason Gerecke 2016-07-06 23:24:48 UTC
Created attachment 330973 [details] [review]
Fix for the crash bug

Thanks for the GDK_SYNCHRONIZE=1 tip, that made things deterministic enough to pinpoint the problem areas. Now that I've been able to do that, I've been able to write up that patch you were hoping would appear ;)
Comment 11 Jason Gerecke 2016-07-06 23:25:36 UTC
Created attachment 330974 [details] [review]
Bonus memory leak fixes

I also noticed a few memory leaks while running g-s-d under valgrind and have created a patch for them as well.
Comment 12 Jason Gerecke 2016-08-22 16:16:15 UTC
Any chance of these patches getting pulled into master before the code freeze three weeks hence?
Comment 13 Carlos Garnacho 2016-08-22 18:09:29 UTC
Gee, indeed, sorry about this. Although, might be "in vain", After wayland tablet v2 support was merged in master, I'm looking into implementing the mutter tablet configuration bits in mutter for x11/libinput. If I get that in time the g-s-d wacom plugin/settings will be phased out.

Still, worth to push in the mean time, even backport. I am doing that now.