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 774699 - [wintab, potential segfault]: list iteration regression causes odd-indexed devices to be ignored during lookup & e.g. present no pressure
[wintab, potential segfault]: list iteration regression causes odd-indexed de...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
3.22.x
Other Linux
: Normal critical
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks: 774265
 
 
Reported: 2016-11-19 03:57 UTC by Andrew Chadwick
Modified: 2016-11-21 18:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-wintab-fix-skipping-of-odd-numbered-devices.patch (1.40 KB, patch)
2016-11-19 04:07 UTC, Andrew Chadwick
committed Details | Review

Description Andrew Chadwick 2016-11-19 03:57:11 UTC
Commit 4ce6d1060104e7072eec347370999bfd3fe69dc0 introduces a list iteration bug whereby devices with alternate entries in the manager's wintab_devices list will be passed over during lookup.

https://github.com/GNOME/gtk/commit/4ce6d1060104e7072eec347370999bfd3fe69dc0

This new code is probably a big source of more recent "wintab device does not have pressure" bugs for us, because it is used to find the Wintab device for a native windowing message from the tablet driver for each motion event. If the device has an odd zero-based position in the list, it will be skipped over even if the corresponding event had pressure.

(Unaffected: Wacom Intuos 5 M. Affected: Huion H610PRO. Could be ~50% of devices out there.)

More importantly, the wintab event handling code currently carries a potential for a segfault if the wintab_devices list has an even length and no even-indexed devices in the list "do" pressure.

This code is present in master and on the gtk-3-22 stable branch. It affects versions of GTK between 3.19.9 and 3.22.4 inclusive.

I will attach a tested patch against stable shortly.
Comment 1 Andrew Chadwick 2016-11-19 04:07:53 UTC
Created attachment 340281 [details] [review]
0001-wintab-fix-skipping-of-odd-numbered-devices.patch

Briefly tested patch against gtk-3-22. Fixes pressure for one of my broken tablets at least.

Also fix up the comparison for coding style.

Please could this be applied to the stable and master branches?
Comment 2 Andrew Chadwick 2016-11-19 04:15:30 UTC
Correction^^: [...] if the wintab_devices list has an odd length and [...]
Comment 3 Carlos Garnacho 2016-11-19 16:34:00 UTC
Comment on attachment 340281 [details] [review]
0001-wintab-fix-skipping-of-odd-numbered-devices.patch

Indeed...
Comment 4 Andrew Chadwick 2016-11-20 17:09:48 UTC
[[This comment is duplicated into the 3 active Wintab bugs, sorry for the spam]]

Okay, big testing rollup. Incorporating the following patches was *VERY* positive, getting rid of all inti-time crashes and almost all missing pressure. Tilt and eraser are back online and looking good for more advanced tablets.

* bug 774699 comment 1
  "0001-wintab-fix-skipping-of-odd-numbered-devices.patch"
* bug 774379 comment 29
  "0001-wintab-init-only-after-the-display-is-assigned.patch"
* bug 774379 comment 20
  "0001-Fix-segfault-during-init-for-some-wintab32-DLLs.patch"
* Sorry LRN, your patch from bug 774379 comment 26 didn't apply cleanly
  onto the stable branch (gtk-3-22) alongside all my patches. I was not
  able to test it.
* bug 774265 comment 12
  "0001-win32-Fix-tilt-from-Wintab-devices.patch"

I made a debug build and installation on MSYS2 of all the software needed, for both i686 and x86_64, and tested them all from their appropriate MSYS2 shell.

Arch    Tablet model                      Drivers   gtk3-demo  mypaint-git
----    -------------                     -------   ---------  ------------
x86_64  Huion H610PRO                     12.2.16   OK         OK
i686    Huion H610PRO                     12.2.16   OK         OK
x86_64  Wacom Intuos 5 M (PTH-650)        6.3.18-5  OK +T +E   OK +T +E
i686    Wacom Intuos 5 M (PTH-650)        6.3.18-5  OK +T +E   OK +T +E
x86_64  Genius EasyPen i405X (GT-100007)  2.5.1.1*  OK         OK
i686    Genius EasyPen i405X (GT-100007)  2.5.1.1*  NOEVENTS   NOEVENTS

My system is AMD64, so it is possible that the Genius driver installers made a decision about what to install for me. It is possible we've seen this behaviour before in MyPaint-land, so the lone failure above isn't a worry for me right now.

Key
---
NOEVENTS  Device presents only as "System Aggregated Pointer", and does
          not send events with pressure. Evidence of wintab32.dll
          being loaded by wintab_init_check, though!
OK  Device presents as something other than "System Aggregated Pointer",
    and sends events with pressure.
+T  Device also correctly presents tilt.
+E  Device also presents the eraser end of the stylus as a named device.
*  Drivers are branded "ioTablet", manufacturer "KYE",
   but were downloaded from geniusnet.com as recommended.
Comment 5 Andrew Chadwick 2016-11-20 17:20:46 UTC
This one is already accepted-commit_now, so I'm not nagging. Thanks for the review, carlosg.
Comment 6 Ignacio Casal Quinteiro (nacho) 2016-11-21 18:11:49 UTC
Thanks