rshk / python-libxdo

Python bindings for libxdo
BSD 3-Clause "New" or "Revised" License
76 stars 19 forks source link

Failed activate_window crashes the interpreter #24

Open theicfire opened 4 years ago

theicfire commented 4 years ago

X errors don't get caught when calling activate_window, like they do for other commands as mentioned in https://github.com/rshk/python-libxdo/issues/6.

Here's how to reproduce the issue:

$ python
Python 2.7.15+ (default, Oct  7 2019, 17:39:04)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xdo
>>> x = xdo.Xdo()
>>> x.activate_window(123)
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 315, in 'calling callback function'
  File "/home/ubuntu/.local/lib/python2.7/site-packages/xdo/__init__.py", line 69, in _handle_x_error
    raise XError('Event: {}'.format(evt))
xdo.XError: Event: <xdo.xdo.LP_XErrorEvent object at 0x7f946f070dd0>
XGetWindowProperty failed!Segmentation fault (core dumped)
$

It may be the case that it's not possible to fix this issue without either: a) Modifying xdotool itself b) Forking a process and running xdo from there. That process can then crash without the main python process crashing. c) Checking that the window is valid before sending some of these commands, but that could cause a race condition

mdborhanuddin commented 3 years ago

Hitting similar issue as follows-

xdo.XError: Event: <xdo.xdo.LP_XErrorEvent object at 0x7f48803b1158>
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 234, in 'calling callback function'
  File "/home/muddin/.local/lib/python3.6/site-packages/xdo/__init__.py", line 69, in _handle_x_error
    raise XError('Event: {}'.format(evt))
xdo.XError: Event: <xdo.xdo.LP_XErrorEvent object at 0x7f48803a8f28>
corrupted double-linked list
Aborted (core dumped)

Any clue to fix the above or any workaround?

theicfire commented 3 years ago

I just stopped using this library to get around the issue. I now just use xlib/xcb directly instead.