jordansissel / xdotool

fake keyboard/mouse input, window management, and more
Other
3.25k stars 319 forks source link

xdotool Segmentation fault when run in VNC #126

Open dimecoin opened 8 years ago

dimecoin commented 8 years ago

If i run xdotool on a real display (ie, Display :0 with real videocard/monitor), it works fine. But if I run under VNC display, it gives segfault:

$ export DISPLAY=:0  
$ xdotool getmouselocation
x:35 y:31 screen:0 window:25165825
$ export DISPLAY=:1
$ xdotool getmouselocation
Segmentation fault
$

$ gdb --args xdotool getmouselocation
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 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-linux-gnu".
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 xdotool...(no debugging symbols found)...done.
(gdb) r
Starting program: /usr/bin/xdotool getmouselocation
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd746f in xdo_new_with_opened_display () from /usr/lib/x86_64-linux-gnu/libxdo.so.3
(gdb) f
#0  0x00007ffff7bd746f in xdo_new_with_opened_display () from /usr/lib/x86_64-linux-gnu/libxdo.so.3
(gdb) q
A debugging session is active.

        Inferior 1 [process 27403] will be killed.

Quit anyway? (y or n) n
Not confirmed.
(gdb) n
Single stepping until exit from function xdo_new_with_opened_display,
which has no line number information.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) f
No stack.
(gdb) q
$

System info

Debian 8 (Jessie), x86_64 Linux server 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux

Tried using using the following VNC servers (segfault on each) :

vnc4server 4.1.1+X4.3.0-37.6 
tightvncserver 1.3.9-6.5

Using xdotool package:

 xdotool 1:3.20140805.1-2
$ xdotool -v
xdotool version 3.20141006.1

vnc/xdotool all installed though debian's package management system (apt-get)

Let me know if I can provide any more information.

mgobill commented 8 years ago

i'm having this same problem on a raspberry pi 2 running raspbian jessie. please let me know if i can provide any other information as well. thanks for all the hard work!

i'm going to try this again on a raspberry pi 3 in a couple of days to see if the same problem occurs!

Edit: can confirm that this problem occurs on raspberry pi 3 as well

Maltz42 commented 8 years ago

Ditto here - raspberry pi 3 / jessie, everything updated to current.

I even downloaded and compiled the source from here to get a newer version. Which weirdly, -version reports as 3.20141017.1 although CHANGELIST includes notes up to version 3.20160805.1

PhilD41 commented 8 years ago

Also having this issue on Mint 18. It worked fine prior to upgrading. Is there a solution or work-around for this other than reverting back to Mint 17.3? It is really becoming problematic for me. Thanks!

jordansissel commented 8 years ago

I tried to reproduce this using tigervnc:

# Start my X VNC server
% Xvnc :1

Xvnc TigerVNC 1.6.0 - built Jan  4 2016 15:12:19
Copyright (C) 1999-2015 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 11800000, The X.Org Foundation

Tue Aug 16 22:01:33 2016
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on all interface(s), port 5901
 vncext:      created VNC server for screen 0
# Try to get mouse info from xdotool:
% xdotool getmouselocation
x:512 y:384 screen:0 window:616

It's working for me :\

Maltz42 commented 8 years ago

Try it with tightvnc, that's what I'm having trouble with on a Raspberry Pi, as was dimecoin. I've run across this in other threads around the net, and it seems to usually be that combination, which I imagine is very popular since the Raspberry Pi website VNC instructions walks you through installing tightvnc, and Raspberry Pi is often a good use case for xdotool.

mgobill commented 8 years ago

oh wow, thanks for following up jordan! i love xdotool. but i agree with Maltz42, i was also using tightVNC on a fresh install of raspbian jessie and raspbian wheezy (i use raspberry pis a lot!). please let me know how i can help! thanks again!

PhilD41 commented 8 years ago

I can confirm that xdotools works as expected on Linux Mint 18 with tigervncserver installed vs. tightvncserver. I am not sure what tightvnc changed but it is not compatible. I am very pleased to have this functioning again. Thank you @jordansissel !!

jordansissel commented 8 years ago

Ok cool thanks for the details about tightvnc maybe being a factor. I will test this specifically!

On Wednesday, August 17, 2016, mgobill notifications@github.com wrote:

oh wow, thanks for following up jordan! i love xdotool. but i agree with Maltz42, i was also using tightVNC on a fresh install of raspbian jessie and raspbian wheezy (i use raspberry pis a lot!). please let me know how i can help! thanks again!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jordansissel/xdotool/issues/126#issuecomment-240418110, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIC6lF5L1Hp0VNN6ZN-9SoZ-1iagC0Tks5qgxKBgaJpZM4JInL7 .

jordansissel commented 8 years ago

I am able to reproduce this with tightvnc:

% Xvnc :1
17/08/16 23:38:27 Xvnc version TightVNC-1.3.9
%  DISPLAY=:1 xdotool getmouselocation
segmentation fault 
jordansissel commented 8 years ago

The crash is here:

(gdb) run
Starting program: /home/jls/projects/xdotool/xdotool getmouselocation
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd806b in _xdo_populate_charcode_map (xdo=0x61bb60) at xdo.c:1313
1313        groups = XkbKeyNumGroups(desc, keycode);

The failure is because desc is NULL. desc is set by this:

  XkbDescPtr desc = XkbGetMap(xdo->xdpy, XkbAllClientInfoMask, XkbUseCoreKbd);

I'm not sure what to make of this. It seems like tightvnc doesn't support Xkb. I'm not sure what the correct fix for this would be, yet, anyway.

jordansissel commented 8 years ago

The bbf0e70a commit switched to using Xkb to better support systems with multiple keyboards (I think?). Maybe the solution to this is that if XkbGetMap fails, we should fall back to the older implementation (before xkb was used). I think this would work for tightvnc, but I haven't tested.

jordansissel commented 8 years ago

As a workaround, y'all can use edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8 (from December 2013) as a git commit and is successful on tightvnc:

% git checkout edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8
% make install
% DISPLAY=:1 xdotool getmouselocation
x:320 y:240 screen:0 window:37
mgobill commented 8 years ago

great! thank you so much for looking into and and getting back to us!

toschneck commented 8 years ago

thanks for this hint! tigervnc works great!

jeroenmeulenaar commented 7 years ago

Would it be much work to fix/workaround this for vnc4server?

jordansissel commented 7 years ago

I am not sure. We can try making one :)

On Sat, Jan 7, 2017 at 4:29 AM Jeroen Meulenaar notifications@github.com wrote:

Would it be much work to fix/workaround this for vnc4server?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/jordansissel/xdotool/issues/126#issuecomment-271080852, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIC6suIEs7lrCGVQkC74_ZwMhiBRZTIks5rP4UVgaJpZM4JInL7 .

jeroenmeulenaar commented 7 years ago

I checked out edbbb7a and that version indeed works with vnc4server, so maybe that's already enough workaround for me now :).

I don't think I know enough about the X window system to really code something myself... I'd be happy to test other solutions.

jtmfam commented 7 years ago

Jordan, Would you mind making a git branch with the fix in it? xdotool-3.20150503.1.tar.gz gives a segmentation fault. Git is telling me that the commit is gone and part of the branch (two years newer.)

git remote add origin https://github.com/jordansissel/xdotool.git git fetch origin edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8 error: no such remote ref edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8

Thanks In Advance

jordansissel commented 7 years ago

@jtmfam According to github, edbbb7a is in the following branches/tags:

branches: master

tags: v3.20160805.1 v3.20160804.2 v3.20160804.1 v3.20150503.1

Looks like your .tar.gz you refer to should have this commit?

simoncpu commented 5 years ago

I'm also experiencing this with vnc4server and I've confirmed that edbbb7a addressed the problem. Thanks!

stayprivate commented 5 years ago

FYI. Ubuntu 18.04 tightvnc xdotool crashes. Got git version commit edbbb7a which get rid of the issue, but need to "make xdotool.static"

stayprivate commented 5 years ago

I spoke too soon. xdotool.static key --clearmodifiers Ctrl+Shift+T does nothing. But if I manually type, it works.

TappingEther commented 5 years ago

As a workaround, y'all can use edbbb7a (from December 2013) as a git commit and is successful on tightvnc:

% git checkout edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8
% make install
% DISPLAY=:1 xdotool getmouselocation
x:320 y:240 screen:0 window:37

@jordansissel When i run "git checkout edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8" i get an error saying : "fatal: not a git repository (or any of the parent directories): .git"

FYI. Ubuntu 18.04 tightvnc xdotool crashes. Got git version commit edbbb7a which get rid of the issue, but need to "make xdotool.static"

@stayprivate Are you not getting segmentation fault (core dumped) anymore?

wjandrea commented 5 years ago

@TappingEther

When i run "git checkout edbbb7a" i get an error saying : "fatal: not a git repository (or any of the parent directories): .git"

You're in the wrong folder

valdisvi commented 5 years ago

I solved this with a workaround:

  1. Enabled autologin for user (e.g. for Lubuntu)
  2. Then shared tty7 session with x11vnc.
gitlopao commented 3 years ago

I tried edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8 and was even able to compile it after installing more x11 libraries

But now running xdotool won't even run and reports this error

homelx01:~/work_area/github_repos/xdotool$ xdotool xdotool: symbol lookup error: xdotool: undefined symbol: xdo_close_window

What did I screw up :) ?

Thank you

philippludwig commented 1 year ago

At least on the current raspian edbbb7a does fix this issue, but only if you use xdotool.static, for whatever reason.

Kvach-Lukich commented 9 months ago

Anyone can explain what needed for last debian 12 libx11-dev libxtst-dev libxkbcommon-dev libxinerama-dev can't aderstand whot is xi lib? make static && install static from curent master repo? Right?

Kvach-Lukich commented 9 months ago

Ok for debian users 1.apt install libx11-dev libxtst-dev libxkbcommon-dev libxinerama-dev copy from console additional packages The following additional packages will be installed: libpthread-stubs0-dev libxau-dev libxcb1-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev x11proto-dev xorg-sgml-doctools xtrans-dev Suggested packages: libx11-doc libxcb-doc libxext-doc The following NEW packages will be installed: libpthread-stubs0-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxkbcommon-dev libxtst-dev x11proto-dev xorg-sgml-doctools xtrans-dev

  1. git clone https://github.com/jordansissel/xdotool.git cd xdotool
  2. git checkout edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8
  3. make static
  4. chmod 777 xdotool.static for tightvnc export DISPLAY=:1.0 ./xdotool.static mousemove 1000 1000 must vorking
    1. apt purge libpthread-stubs0-dev libxau-dev libxcb1-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev x11proto-dev xorg-sgml-doctools xtrans-dev libpthread-stubs0-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxkbcommon-dev libxtst-dev x11proto-dev xorg-sgml-doctools xtrans-dev remove all garbage
TMSL commented 2 months ago

FYI: the "xdotool.static" version and steps listed by Kvach-Lukich (thanks!) in post https://github.com/jordansissel/xdotool/issues/126#issuecomment-1925878536 also appear to work on my Libre Renegade (pi 'clone') running Armbian on an arm64 processor.

As a check, I did a build of the current xdotool (today 8-Sep-2024) and got the Segmentation Fault issue.

I'm running tightvncserver as a service on display :0. Also checked it running on demand using display :1. https://github.com/jordansissel/xdotool/commit/edbbb7a8f664ceacbb2cffbe8ee4f5a26b5addc8 version works for both.

full uname info: Linux renegade 6.6.39-current-rockchip64 #1 SMP PREEMPT Thu Jul 11 10:49:22 UTC 2024 aarch64 GNU/Linux