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 764664 - Segfault when initializing WINTAB pressure-sensitive tablets (Wacom, Huion, ...)
Segfault when initializing WINTAB pressure-sensitive tablets (Wacom, Huion, ...)
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
3.20.x
Other Windows
: Normal blocker
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-04-06 00:46 UTC by Andrew Chadwick
Modified: 2016-04-11 20:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
win32: rollback change and use _gdk_window (1.19 KB, patch)
2016-04-11 20:24 UTC, Ignacio Casal Quinteiro (nacho)
committed Details | Review

Description Andrew Chadwick 2016-04-06 00:46:22 UTC
Downstream issue: https://github.com/mypaint/mypaint/issues/636 (user-level details and a bit more)

Programs using WINTAB drivers crash immediately when the program starts. Affects multiple Huion and Wacom drivers. Reproducible with hardware in MSYS2's gtk3 packages, 3.20.1 and 3.20.2. Version 3.18.6 is unaffected.

Before 3.20.2, there was a CRITICAL which seems to have been removed in 3.20.2:

> (python2.exe:3160): Gdk-CRITICAL **: _gdk_win32_display_create_window_impl: assertion 'display == gdk_display_get_default ()' failed

I do not know if it it's related, but it might indicate where/when to look.
Comment 1 Andrew Chadwick 2016-04-06 03:17:13 UTC
Affects gtk3-demo too, not just programs actually trying to use tablet input.

Backtrace for debug+unstripped builds of MSYS2's gtk3 3.20.2-1 and glib2 2.48.0-3 for x86_64. With Wacom PTH-650 inserted at program start, gtk3-demo segfaults. Without the tablet plugged in at program start, it operates normally.

(As mentioned in the downstream report, users really cannot plug their tablet in after the program has started as a workaround for this bug. The result works as a mouse, but pressure is absent.)


$ gdb -ex r --args gtk3-demo
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gtk3-demo...(no debugging symbols found)...done.
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 5724.0x1670]
[New Thread 5724.0x1284]
[New Thread 5724.0x1530]
[New Thread 5724.0x1790]
[New Thread 5724.0x388]
[New Thread 5724.0x117c]
[New Thread 5724.0x16c4]
[New Thread 5724.0xd90]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000070eea1f6 in ?? () from C:\msys64\mingw64\bin\libgdk-3-0.dll
(gdb) bt
  • #0 ??
    from C:\msys64\mingw64\bin\libgdk-3-0.dll
  • #1 g_object_new_internal
    at ../../glib-2.48.0/gobject/gobject.c line 1821
  • #2 g_object_new_valist
    at ../../glib-2.48.0/gobject/gobject.c line 2040
  • #3 g_object_new
    at ../../glib-2.48.0/gobject/gobject.c line 1624
  • #4 ??
    from C:\msys64\mingw64\bin\libgdk-3-0.dll
  • #5 ??
    from C:\msys64\mingw64\bin\libgdk-3-0.dll
  • #6 ??
    from C:\msys64\mingw64\bin\libgtk-3-0.dll
  • #7 ??
    from C:\msys64\mingw64\bin\libgtk-3-0.dll
  • #8 ??
    from C:\msys64\mingw64\bin\libgtk-3-0.dll
  • #9 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #10 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #11 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #12 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #13 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #14 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #15 g_application_register
    at ../../glib-2.48.0/gio/gapplication.c line 2049
  • #16 g_application_real_local_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 1012
  • #17 g_application_run
    at ../../glib-2.48.0/gio/gapplication.c line 2350
  • #18 ??
  • #19 ??
  • #20 ??
  • #21 KERNEL32!BaseThreadInitThunk
    from C:\Windows\system32\kernel32.dll
  • #22 ntdll!RtlUserThreadStart
    from C:\Windows\SYSTEM32\ntdll.dll
  • #23 ??
A debugging session is active.

        Inferior 1 [process 5724] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]

$
Comment 2 Andrew Chadwick 2016-04-06 03:29:56 UTC
Downgrading the glib2 package to non-debug 2.44.1 doesn't fix this (and the backtrace still refers to 2.48... let me know if you would like me to rebuild gtk3 against debug glib or something like that - these two debug builds were done in parallel against stock MSYS2 <everything-else>).

Downgrading the gtk3 package alone to 3.18.6 *is* sufficient to fix this problem.
Comment 3 Andrew Chadwick 2016-04-06 16:11:06 UTC
Better backtrace. Somehow my debug build didn't have symbols available before. This is with the Huion tablet not plugged in, just with its manufacturer's drivers installed at their latest version (V12.2.14 from https://www.huiontablet.com/all-products/graphic-tablets/h610.html → Download tab → "Driver for HUION H610", click on the Windows logo). Anyone can reproduce this regardless of whether they own actual tablet hardware, I hope :) 

Wacom tablets require the tablet to be plugged in at startup for the crash to happen. I'll drop a trace in from that scenario shortly for confirmation.



$ gdb -ex r --args gtk3-demo
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gtk3-demo...done.
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 1940.0x6dc]
[New Thread 1940.0xeb4]
[New Thread 1940.0xff4]
[New Thread 1940.0xe14]
[New Thread 1940.0xe58]
[New Thread 1940.0x74c]
[New Thread 1940.0xd90]
warning:        WTContextManager() this:f84de310
warning:        WTRoundArray() this:f84deb90

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000070eeb46e in wintab_init_check (device_manager=0x202b280)
    at gdkdevicemanager-win32.c:512
512           if ((*hctx = (*p_WTOpenA) (GDK_WINDOW_HWND (wintab_window), &lc, TRUE)) == NULL)
(gdb) bt full
  • #0 wintab_init_check
    at gdkdevicemanager-win32.c line 512
  • #1 gdk_device_manager_win32_constructed
    at gdkdevicemanager-win32.c line 730
  • #2 g_object_new_internal
    at ../../glib-2.48.0/gobject/gobject.c line 1821
  • #3 g_object_new_valist
    at ../../glib-2.48.0/gobject/gobject.c line 2040
  • #4 g_object_new
    at ../../glib-2.48.0/gobject/gobject.c line 1624
  • #5 _gdk_win32_display_open
    at gdkdisplay-win32.c line 239
  • #6 gdk_display_manager_open_display
    at gdkdisplaymanager.c line 472
  • #7 gdk_display_open
    at gdkdisplay.c line 1917
  • #8 gdk_display_open_default
    at gdk.c line 443
  • #9 gtk_init_check
    at gtkmain.c line 1047
  • #10 gtk_init
    at gtkmain.c line 1104
  • #11 gtk_init_abi_check
    at gtkmain.c line 1162
  • #12 gtk_application_startup
    at gtkapplication.c line 631
  • #13 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #14 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #15 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #16 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #17 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #18 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #19 g_application_register
    at ../../glib-2.48.0/gio/gapplication.c line 2049
  • #20 g_application_real_local_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 1012
  • #21 gtk_application_local_command_line
    at gtkapplication.c line 670
  • #22 g_application_run
    at ../../glib-2.48.0/gio/gapplication.c line 2350
  • #23 main
    at main.c line 1180

Comment 4 Andrew Chadwick 2016-04-06 17:11:41 UTC
And again, this time from a plugged-in Wacom device. Debug build of GTK 3.20.2 as in comment 3.



$ gdb -ex r --args gtk3-demo
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gtk3-demo...done.
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 3464.0xb94]
[New Thread 3464.0x368]
[New Thread 3464.0xc74]
[New Thread 3464.0x540]
[New Thread 3464.0xf60]
[New Thread 3464.0x378]
[New Thread 3464.0xd90]
[New Thread 3464.0xe40]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000070eeb46e in wintab_init_check (device_manager=0x1fab280)
    at gdkdevicemanager-win32.c:512
512           if ((*hctx = (*p_WTOpenA) (GDK_WINDOW_HWND (wintab_window), &lc, TRUE)) == NULL)
(gdb) bt full
  • #0 wintab_init_check
    at gdkdevicemanager-win32.c line 512
  • #1 gdk_device_manager_win32_constructed
    at gdkdevicemanager-win32.c line 730
  • #2 g_object_new_internal
    at ../../glib-2.48.0/gobject/gobject.c line 1821
  • #3 g_object_new_valist
    at ../../glib-2.48.0/gobject/gobject.c line 2040
  • #4 g_object_new
    at ../../glib-2.48.0/gobject/gobject.c line 1624
  • #5 _gdk_win32_display_open
    at gdkdisplay-win32.c line 239
  • #6 gdk_display_manager_open_display
    at gdkdisplaymanager.c line 472
  • #7 gdk_display_open
    at gdkdisplay.c line 1917
  • #8 gdk_display_open_default
    at gdk.c line 443
  • #9 gtk_init_check
    at gtkmain.c line 1047
  • #10 gtk_init
    at gtkmain.c line 1104
  • #11 gtk_init_abi_check
    at gtkmain.c line 1162
  • #12 gtk_application_startup
    at gtkapplication.c line 631
  • #13 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #14 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #15 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #16 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #17 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #18 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #19 g_application_register
    at ../../glib-2.48.0/gio/gapplication.c line 2049
  • #20 g_application_real_local_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 1012
  • #21 gtk_application_local_command_line
    at gtkapplication.c line 670
  • #22 g_application_run
    at ../../glib-2.48.0/gio/gapplication.c line 2350
  • #23 main
    at main.c line 1180

Comment 5 Paolo Borelli 2016-04-06 17:19:25 UTC
Blind guess: could you try to add gdk_window_ensure_native at line 451 of gdkdevicemanager-win32.c ?

Something like:

...
  wa.window_type = GDK_WINDOW_TOPLEVEL;
  if ((wintab_window = gdk_window_new (root, &wa, GDK_WA_X | GDK_WA_Y)) == NULL)
    {
      g_warning ("gdk_input_wintab_init: gdk_window_new failed");
      return;
    }
  g_object_ref (wintab_window);

  gdk_window_ensure_native (wintab_window);

  for (devix = 0; devix < ndevices; devix++)
    {
...


Basically I am wondering if wintab_window actually has window->impl->hwnd




More in general I do not understand why this code needs to create a GdkWindow if it just needs a native handle... wouldn't it be better to just use CreateWindow etc?
Comment 6 Ignacio Casal Quinteiro (nacho) 2016-04-06 19:18:07 UTC
Can you please give us also the bt using --g-fatal-warnings?
Comment 7 Andrew Chadwick 2016-04-06 23:41:57 UTC
nacho: with the same 3.20.2 build as in comment 4 and comment 3, *with no Wacom attached at startup*:

$ gdb -ex r --args gtk3-demo --g-fatal-warnings
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gtk3-demo...done.
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe --g-fatal-warnings
[New Thread 3960.0x8dc]
[New Thread 3960.0x1010]
[New Thread 3960.0xf1c]
[New Thread 3960.0x1340]
[New Thread 3960.0x10c0]
[New Thread 3960.0xccc]
[New Thread 3960.0x12b4]
[New Thread 3960.0xc9c]

Thread 1 received signal SIGTRAP, Trace/breakpoint trap.
0x00000000685f816b in _g_log_abort (breakpoint=1)
    at ../../glib-2.48.0/glib/gmessages.c:325
325         G_BREAKPOINT ();
(gdb) bt full
  • #0 _g_log_abort
    at ../../glib-2.48.0/glib/gmessages.c line 325
  • #1 g_logv
    at ../../glib-2.48.0/glib/gmessages.c line 1078
  • #2 g_log
    at ../../glib-2.48.0/glib/gmessages.c line 1119
  • #3 g_return_if_fail_warning
  • #4 _gdk_win32_display_create_window_impl
    at gdkwindow-win32.c line 646
  • #5 _gdk_display_create_window_impl
    at gdkdisplay.c line 2178
  • #6 gdk_window_new
    at gdkwindow.c line 1432
  • #7 wintab_init_check
    at gdkdevicemanager-win32.c line 444
  • #8 gdk_device_manager_win32_constructed
    at gdkdevicemanager-win32.c line 730
  • #9 g_object_new_internal
    at ../../glib-2.48.0/gobject/gobject.c line 1821
  • #10 g_object_new_valist
    at ../../glib-2.48.0/gobject/gobject.c line 2040
  • #11 g_object_new
    at ../../glib-2.48.0/gobject/gobject.c line 1624
  • #12 _gdk_win32_display_open
    at gdkdisplay-win32.c line 239
  • #13 gdk_display_manager_open_display
    at gdkdisplaymanager.c line 472
  • #14 gdk_display_open
    at gdkdisplay.c line 1917
  • #15 gdk_display_open_default
    at gdk.c line 443
  • #16 gtk_init_check
    at gtkmain.c line 1047
  • #17 gtk_init
    at gtkmain.c line 1104
  • #18 gtk_init_abi_check
    at gtkmain.c line 1162
  • #19 gtk_application_startup
    at gtkapplication.c line 631
  • #20 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #21 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #22 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #23 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #24 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #25 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #26 g_application_register
    at ../../glib-2.48.0/gio/gapplication.c line 2049
  • #27 g_application_real_local_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 1012
  • #28 gtk_application_local_command_line
    at gtkapplication.c line 670
  • #29 g_application_run
    at ../../glib-2.48.0/gio/gapplication.c line 2350
  • #30 main
    at main.c line 1180

Comment 8 Andrew Chadwick 2016-04-06 23:43:17 UTC
nacho: and again, the same same 3.20.2 build as in comment 4 and comment 3 and comment 7, this time *with* the Wacom device plugged in at startup.

$ gdb -ex r --args gtk3-demo --g-fatal-warnings
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gtk3-demo...done.
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe --g-fatal-warnings
[New Thread 1100.0xa94]
[New Thread 1100.0x1198]
[New Thread 1100.0x106c]
[New Thread 1100.0x1020]
[New Thread 1100.0xd84]
[New Thread 1100.0x9a4]
[New Thread 1100.0x41c]
[New Thread 1100.0x127c]

Thread 1 received signal SIGTRAP, Trace/breakpoint trap.
0x00000000685f816b in _g_log_abort (breakpoint=1)
    at ../../glib-2.48.0/glib/gmessages.c:325
325         G_BREAKPOINT ();
(gdb) bt full
  • #0 _g_log_abort
    at ../../glib-2.48.0/glib/gmessages.c line 325
  • #1 g_logv
    at ../../glib-2.48.0/glib/gmessages.c line 1078
  • #2 g_log
    at ../../glib-2.48.0/glib/gmessages.c line 1119
  • #3 g_return_if_fail_warning
  • #4 _gdk_win32_display_create_window_impl
    at gdkwindow-win32.c line 646
  • #5 _gdk_display_create_window_impl
    at gdkdisplay.c line 2178
  • #6 gdk_window_new
    at gdkwindow.c line 1432
  • #7 wintab_init_check
    at gdkdevicemanager-win32.c line 444
  • #8 gdk_device_manager_win32_constructed
    at gdkdevicemanager-win32.c line 730
  • #9 g_object_new_internal
    at ../../glib-2.48.0/gobject/gobject.c line 1821
  • #10 g_object_new_valist
    at ../../glib-2.48.0/gobject/gobject.c line 2040
  • #11 g_object_new
    at ../../glib-2.48.0/gobject/gobject.c line 1624
  • #12 _gdk_win32_display_open
    at gdkdisplay-win32.c line 239
  • #13 gdk_display_manager_open_display
    at gdkdisplaymanager.c line 472
  • #14 gdk_display_open
    at gdkdisplay.c line 1917
  • #15 gdk_display_open_default
    at gdk.c line 443
  • #16 gtk_init_check
    at gtkmain.c line 1047
  • #17 gtk_init
    at gtkmain.c line 1104
  • #18 gtk_init_abi_check
    at gtkmain.c line 1162
  • #19 gtk_application_startup
    at gtkapplication.c line 631
  • #20 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #21 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #22 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #23 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #24 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #25 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #26 g_application_register
    at ../../glib-2.48.0/gio/gapplication.c line 2049
  • #27 g_application_real_local_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 1012
  • #28 gtk_application_local_command_line
    at gtkapplication.c line 670
  • #29 g_application_run
    at ../../glib-2.48.0/gio/gapplication.c line 2350
  • #30 main
    at main.c line 1180

Comment 9 Andrew Chadwick 2016-04-07 00:11:22 UTC
Paolo: I patched with

----------------------------------8<--------------------------------
diff -rU2 gtk+-3.20.2.upstream-as-patched/gdk/win32/gdkdevicemanager-win32.c gtk+-3.20.2-mine/gdk/win32/gdkdevicemanager-win32.c
--- gtk+-3.20.2.upstream-as-patched/gdk/win32/gdkdevicemanager-win32.c  2016-03-26 02:46:38.000000000 +0000
+++ gtk+-3.20.2-mine/gdk/win32/gdkdevicemanager-win32.c 2016-04-06 18:37:54.120123700 +0100
@@ -449,4 +449,10 @@
   g_object_ref (wintab_window);

+  if (! gdk_window_ensure_native (wintab_window))
+    {
+      g_warning ("gdk_input_wintab_init: dummy GdkWindow has no native window");
+      return;
+    }
+
   for (devix = 0; devix < ndevices; devix++)
     {
---------------------------------->8-----------------------------------

and rebuilt. That HWND is definitely there.


$ gdb -ex r --args gtk3-demo
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gtk3-demo...done.
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 3232.0x90c]
[New Thread 3232.0x10a4]
[New Thread 3232.0xa9c]
[New Thread 3232.0x160]
[New Thread 3232.0x918]
[New Thread 3232.0x12c]
[New Thread 3232.0x1178]
[New Thread 3232.0x970]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000070eeb48e in wintab_init_check (device_manager=0x209b280)
    at gdkdevicemanager-win32.c:518
518           if ((*hctx = (*p_WTOpenA) (GDK_WINDOW_HWND (wintab_window), &lc, TRUE)) == NULL)
(gdb) break gdkdevicemanager-win32.c:443
Breakpoint 1 at 0x70eeb119: file gdkdevicemanager-win32.c, line 443.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) [answered Y; input not from terminal]
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 4516.0xec0]
[New Thread 4516.0x1208]
[New Thread 4516.0x860]
[New Thread 4516.0x105c]
[New Thread 4516.0xe44]
[New Thread 4516.0x1264]
[New Thread 4516.0x11c8]
[New Thread 4516.0x7d8]

Thread 1 hit Breakpoint 1, wintab_init_check (device_manager=0x1fdb280)
    at gdkdevicemanager-win32.c:443
443       wa.window_type = GDK_WINDOW_TOPLEVEL;
(gdb) l
438       wa.event_mask = GDK_ALL_EVENTS_MASK;
439       wa.width = 2;
440       wa.height = 2;
441       wa.x = -100;
442       wa.y = -100;
443       wa.window_type = GDK_WINDOW_TOPLEVEL;
444       if ((wintab_window = gdk_window_new (root, &wa, GDK_WA_X | GDK_WA_Y)) == NULL)
445         {
446           g_warning ("gdk_input_wintab_init: gdk_window_new failed");
447           return;
(gdb) n
444       if ((wintab_window = gdk_window_new (root, &wa, GDK_WA_X | GDK_WA_Y)) == NULL)
(gdb) n
449       g_object_ref (wintab_window);
(gdb) p wintab_window
$1 = (GdkWindow *) 0x200f1f0
(gdb) n
451       if (! gdk_window_ensure_native (wintab_window))
(gdb) p wintab_window
$2 = (GdkWindow *) 0x200f1f0
(gdb) n
467           (*p_WTInfoW) (WTI_DEVICES + devix, DVC_NAME, devname);
(gdb) n
0x000007fef10960ff in Wintab32!WTInfoW ()
   from C:\Windows\system32\Wintab32.dll
(gdb) c
Continuing.
[New Thread 4516.0x1194]
[Thread 4516.0x860 exited with code 0]
[New Thread 4516.0xadc]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000070eeb48e in wintab_init_check (device_manager=0x1fdb280)
    at gdkdevicemanager-win32.c:518
518           if ((*hctx = (*p_WTOpenA) (GDK_WINDOW_HWND (wintab_window), &lc, TRUE)) == NULL)
(gdb) p wintab_window
$3 = (GdkWindow *) 0x200f1f0
(gdb) bt full
  • #0 wintab_init_check
    at gdkdevicemanager-win32.c line 518
  • #1 gdk_device_manager_win32_constructed
    at gdkdevicemanager-win32.c line 736
  • #2 g_object_new_internal
    at ../../glib-2.48.0/gobject/gobject.c line 1821
  • #3 g_object_new_valist
    at ../../glib-2.48.0/gobject/gobject.c line 2040
  • #4 g_object_new
    at ../../glib-2.48.0/gobject/gobject.c line 1624
  • #5 _gdk_win32_display_open
    at gdkdisplay-win32.c line 239
  • #6 gdk_display_manager_open_display
    at gdkdisplaymanager.c line 472
  • #7 gdk_display_open
    at gdkdisplay.c line 1917
  • #8 gdk_display_open_default
    at gdk.c line 443
  • #9 gtk_init_check
    at gtkmain.c line 1047
  • #10 gtk_init
    at gtkmain.c line 1104
  • #11 gtk_init_abi_check
    at gtkmain.c line 1162
  • #12 gtk_application_startup
    at gtkapplication.c line 631
  • #13 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #14 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #15 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #16 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #17 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #18 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #19 g_application_register
    at ../../glib-2.48.0/gio/gapplication.c line 2049
  • #20 g_application_real_local_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 1012
  • #21 gtk_application_local_command_line
    at gtkapplication.c line 670
  • #22 g_application_run
    at ../../glib-2.48.0/gio/gapplication.c line 2350
  • #23 main
    at main.c line 1180

Comment 10 Andrew Chadwick 2016-04-07 00:19:08 UTC
Wait, what.

[N.b. below is probably me misunderstanding gdb. Forgive me, I'm a Python guy.]

$ gdb -ex r --args gtk3-demo
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gtk3-demo...done.
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 1668.0xcc0]
[New Thread 1668.0x9a4]
[New Thread 1668.0xf70]
[New Thread 1668.0x1d0]
[New Thread 1668.0x41c]
[New Thread 1668.0x368]
[New Thread 1668.0x180]
[New Thread 1668.0x127c]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000070eeb48e in wintab_init_check (device_manager=0x67b280)
    at gdkdevicemanager-win32.c:518
518           if ((*hctx = (*p_WTOpenA) (GDK_WINDOW_HWND (wintab_window), &lc, TRUE)) == NULL)
(gdb) break gdkdevicemanager-win32.c:443
Breakpoint 1 at 0x70eeb119: file gdkdevicemanager-win32.c, line 443.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) [answered Y; input not from terminal]
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 1664.0x1018]
[New Thread 1664.0x10b4]
[New Thread 1664.0x118c]
[New Thread 1664.0x130]
[New Thread 1664.0xdb0]
[New Thread 1664.0xd28]
[New Thread 1664.0xd1c]
[New Thread 1664.0xd80]

Thread 1 hit Breakpoint 1, wintab_init_check (device_manager=0x1fab280)
    at gdkdevicemanager-win32.c:443
443       wa.window_type = GDK_WINDOW_TOPLEVEL;
(gdb) l
438       wa.event_mask = GDK_ALL_EVENTS_MASK;
439       wa.width = 2;
440       wa.height = 2;
441       wa.x = -100;
442       wa.y = -100;
443       wa.window_type = GDK_WINDOW_TOPLEVEL;
444       if ((wintab_window = gdk_window_new (root, &wa, GDK_WA_X | GDK_WA_Y)) == NULL)
445         {
446           g_warning ("gdk_input_wintab_init: gdk_window_new failed");
447           return;
(gdb) n
444       if ((wintab_window = gdk_window_new (root, &wa, GDK_WA_X | GDK_WA_Y)) == NULL)
(gdb) n
449       g_object_ref (wintab_window);
(gdb) n
451       if (! gdk_window_ensure_native (wintab_window))
(gdb) p wintab_window->impl
$1 = (GdkWindowImpl *) 0x0
(gdb) n
467           (*p_WTInfoW) (WTI_DEVICES + devix, DVC_NAME, devname);
(gdb) p wintab_window->impl
$2 = (GdkWindowImpl *) 0x0
(gdb) p wintab_window->impl->hwnd
There is no member named hwnd.
(gdb) q
Comment 11 Ignacio Casal Quinteiro (nacho) 2016-04-07 07:12:52 UTC
I think I know the reason:
 - when the display is opened the device manager is created passing in the display to it.
 - in the device manager constructed we initialize the wintab
 - in the wintab initialization we create a gdk_window which has the assertion where display == default display
 - at this point the default display is still NULL because display_open has not yet returned so _gdk_display is still not set.
Comment 12 Ignacio Casal Quinteiro (nacho) 2016-04-07 07:16:43 UTC
Out of curiosity what if you change  _gdk_display_create_window_impl to have this other assertion?

g_return_if_fail (display == _gdk_display);
Comment 13 Andrew Chadwick 2016-04-07 20:03:10 UTC
nacho: it fails to compile, with

[...]
gdkdisplay.c: In function '_gdk_display_create_window_impl':
gdkdisplay.c:2178:32: error: '_gdk_display' undeclared (first use in this function)
   g_return_if_fail (display == _gdk_display);
                                ^
[...]


$ cat 0090-extra-assert.patch
diff -rU2 gtk+-3.20.2.upstream-as-patched/gdk/gdkdisplay.c gtk+-3.20.2-mine/gdk/gdkdisplay.c
--- gtk+-3.20.2.upstream-as-patched/gdk/gdkdisplay.c    2016-03-26 02:46:38.000000000 +0000
+++ gtk+-3.20.2-mine/gdk/gdkdisplay.c   2016-04-07 20:44:28.027523500 +0100
@@ -2176,4 +2176,5 @@
                                  gint              attributes_mask)
 {
+  g_return_if_fail (display == _gdk_display);
   GDK_DISPLAY_GET_CLASS (display)->create_window_impl (display,
                                                        window,
Comment 14 Andrew Chadwick 2016-04-07 20:10:42 UTC
I hope I've given enough information for people who know the GTK codebase better than I do to help debug and fix this. The presence of installed Huion drivers alone on Win7 is enough to trigger this in 3.20.{1,2}, although it can be triggered by the presence of both the Wacom drivers and a plugged-in Wacom tablet too. Both tablet models' GTK symptoms are alleviated by reverting to 3.18.6, changing nothing else on the system. Both tablet models' symptoms seem the same in all respects.

Please let me know if you want me to try anything else, but I won't have a great deal of time available over the upcoming weekend to help diagnose this bug myself.
Comment 15 Ignacio Casal Quinteiro (nacho) 2016-04-07 21:46:53 UTC
Please try somethign like this:

--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -643,7 +643,7 @@ _gdk_win32_display_create_window_impl (GdkDisplay    *display,
   /* check consistency of redundant information */
   guint remaining_mask = attributes_mask;
 
-  g_return_if_fail (display == gdk_display_get_default ());
+  g_return_if_fail (display == _gdk_display);
 
   GDK_NOTE (MISC,
            g_print ("_gdk_window_impl_new: %s %s\n",
Comment 16 Andrew Chadwick 2016-04-08 00:22:53 UTC
nacho: fixing the assertion fixes the segfault. With that patch:


$ gdb -ex r --args gtk3-demo
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gtk3-demo...done.
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 2020.0x125c]
[New Thread 2020.0xa78]
[New Thread 2020.0xc98]
[New Thread 2020.0xb48]
[New Thread 2020.0xebc]
[New Thread 2020.0xc8c]
[New Thread 2020.0xd58]
[New Thread 2020.0x12d0]
[New Thread 2020.0x11f8]
[New Thread 2020.0xef0]
[New Thread 2020.0x10a0]
[Thread 2020.0xebc exited with code 0]
[Thread 2020.0xc8c exited with code 0]
[Thread 2020.0xef0 exited with code 0]
[Thread 2020.0x12d0 exited with code 0]
[Thread 2020.0xb48 exited with code 0]
[Thread 2020.0xa78 exited with code 0]
[Thread 2020.0x10a0 exited with code 0]
[Thread 2020.0x11f8 exited with code 0]
[Thread 2020.0xd58 exited with code 0]
[Thread 2020.0xc98 exited with code 0]
[Inferior 1 (process 2020) exited normally]
(gdb) break gdkwindow-win32.c:646
Breakpoint 1 at 0x70f075ce: file gdkwindow-win32.c, line 646.
(gdb) r
Starting program: C:\msys64\mingw64\bin\gtk3-demo.exe
[New Thread 372.0xfa8]
[New Thread 372.0x132c]
[New Thread 372.0x6ec]
[New Thread 372.0xc68]
[New Thread 372.0x40c]
[New Thread 372.0x2f4]
[New Thread 372.0x264]
[New Thread 372.0x11dc]

Thread 1 hit Breakpoint 1, _gdk_win32_display_create_window_impl (
    display=0x1ffe000, window=0x1fff1f0, real_parent=0x1fff090,
    screen=0x1fcfbd0, event_mask=16777206, attributes=0x22f1d0,
    attributes_mask=12) at gdkwindow-win32.c:646
646       g_return_if_fail (display == _gdk_display);
(gdb) p display
$1 = (GdkDisplay *) 0x1ffe000
(gdb) p _gdk_display
$2 = (GdkDisplay *) 0x1ffe000
(gdb) bt full
  • #0 _gdk_win32_display_create_window_impl
    at gdkwindow-win32.c line 646
  • #1 _gdk_display_create_window_impl
    at gdkdisplay.c line 2178
  • #2 gdk_window_new
    at gdkwindow.c line 1432
  • #3 wintab_init_check
    at gdkdevicemanager-win32.c line 444
  • #4 gdk_device_manager_win32_constructed
    at gdkdevicemanager-win32.c line 736
  • #5 g_object_new_internal
    at ../../glib-2.48.0/gobject/gobject.c line 1821
  • #6 g_object_new_valist
    at ../../glib-2.48.0/gobject/gobject.c line 2040
  • #7 g_object_new
    at ../../glib-2.48.0/gobject/gobject.c line 1624
  • #8 _gdk_win32_display_open
    at gdkdisplay-win32.c line 239
  • #9 gdk_display_manager_open_display
    at gdkdisplaymanager.c line 472
  • #10 gdk_display_open
    at gdkdisplay.c line 1917
  • #11 gdk_display_open_default
    at gdk.c line 443
  • #12 gtk_init_check
    at gtkmain.c line 1047
  • #13 gtk_init
    at gtkmain.c line 1104
  • #14 gtk_init_abi_check
    at gtkmain.c line 1162
  • #15 gtk_application_startup
    at gtkapplication.c line 631
  • #16 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #17 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #18 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #19 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #20 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #21 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #22 g_application_register
    at ../../glib-2.48.0/gio/gapplication.c line 2049
  • #23 g_application_real_local_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 1012
  • #24 gtk_application_local_command_line
    at gtkapplication.c line 670
  • #25 g_application_run
    at ../../glib-2.48.0/gio/gapplication.c line 2350
  • #26 main
    at main.c line 1180
  • #0 _gdk_win32_display_create_window_impl
    at gdkwindow-win32.c line 646
  • #1 _gdk_display_create_window_impl
    at gdkdisplay.c line 2178
  • #2 gdk_window_new
    at gdkwindow.c line 1432
  • #3 gtk_window_realize
    at gtkwindow.c line 7301
  • #4 gtk_application_window_real_realize
    at gtkapplicationwindow.c line 677
  • #5 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #6 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #7 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #8 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #9 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #10 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #11 gtk_widget_realize
    at gtkwidget.c line 5454
  • #12 gtk_window_show
    at gtkwindow.c line 6146
  • #13 g_cclosure_marshal_VOID__VOID
    at ../../glib-2.48.0/gobject/gmarshal.c line 875
  • #14 g_type_class_meta_marshal
    at ../../glib-2.48.0/gobject/gclosure.c line 997
  • #15 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #16 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3559
  • #17 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3385
  • #18 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #19 gtk_widget_show
    at gtkwidget.c line 4784
  • #20 gtk_container_show_all
    at gtkcontainer.c line 3585
  • #21 gtk_widget_show_all
    at gtkwidget.c line 4955
  • #22 activate
    at main.c line 1045
  • #23 command_line
    at main.c line 1091
  • #24 ??
    from C:\msys64\mingw64\bin\libffi-6.dll
  • #25 ??
    from C:\msys64\mingw64\bin\libffi-6.dll
  • #26 g_cclosure_marshal_generic
    at ../../glib-2.48.0/gobject/gclosure.c line 1490
  • #27 g_closure_invoke
    at ../../glib-2.48.0/gobject/gclosure.c line 804
  • #28 signal_emit_unlocked_R
    at ../../glib-2.48.0/gobject/gsignal.c line 3629
  • #29 g_signal_emit_valist
    at ../../glib-2.48.0/gobject/gsignal.c line 3395
  • #30 g_signal_emit
    at ../../glib-2.48.0/gobject/gsignal.c line 3441
  • #31 g_application_call_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 982
  • #32 g_application_real_local_command_line
    at ../../glib-2.48.0/gio/gapplication.c line 1036
  • #33 gtk_application_local_command_line
    at gtkapplication.c line 670
  • #34 g_application_run
    at ../../glib-2.48.0/gio/gapplication.c line 2350
  • #35 main
    at main.c line 1180
Continuing.
[New Thread 372.0xa1c]
[New Thread 372.0x150]
{{{ program opens its main window here -- achadwick }}}
[Thread 372.0x40c exited with code 0]
[Thread 372.0x2f4 exited with code 0]
[Thread 372.0x150 exited with code 0]
[Thread 372.0xcac exited with code 0]
[Thread 372.0x11dc exited with code 0]
[Thread 372.0xc68 exited with code 0]
[Thread 372.0x132c exited with code 0]
[Thread 372.0xa1c exited with code 0]
[Thread 372.0x1370 exited with code 0]
[Thread 372.0x264 exited with code 0]
[Inferior 1 (process 372) exited normally]
(gdb) q
Comment 17 Andrew Chadwick 2016-04-08 00:26:10 UTC
^ That's two traces not one, if anyone's looking at this in the GNOME Bugzilla. Just wanted to confirm how this func comes to be called twice.

Ignore the initial successful run; that's just to get the symbols loaded.
Comment 18 Ignacio Casal Quinteiro (nacho) 2016-04-11 20:24:53 UTC
Created attachment 325749 [details] [review]
win32: rollback change and use _gdk_window

This makes usage of _gdk_window again when creating a window.
This is needed because there is a window created when the display
is being initialized, so it becomes a chicken and egg problem.
For now we roll back this to fix the wintab crash but we might
want to fix this again in the future by improving the wintab
initialization.
Comment 19 Ignacio Casal Quinteiro (nacho) 2016-04-11 20:26:30 UTC
Thanks for the testing!