Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphical emacs doesn't work; spins on poll()/writev()/recvmsg() #611

Closed
aseering opened this issue Jul 1, 2016 · 22 comments
Closed

Graphical emacs doesn't work; spins on poll()/writev()/recvmsg() #611

aseering opened this issue Jul 1, 2016 · 22 comments

Comments

@aseering
Copy link
Contributor

aseering commented Jul 1, 2016

Splitting this out from #187 so that it doesn't get lost.

Steps to reproduce:

  • Install Xming on Windows
  • Install emacs in WSL: sudo apt-get install emacs24
  • Set export DISPLAY=localhost:0 in a WSL terminal
  • Run emacs in the same WSL terminal

Expected:

  • A graphical emacs window should appear, rendered by Xming

Actual:

  • This appears:

2016-07-01 1

And emacs hangs / is unresponsive. The X button in the top-right corner does not close it. Ctrl-C in the WSL terminal window doesn't close it either. It's necessary to get a shell prompt and do a kill -9 to get it to close.

@aseering
Copy link
Contributor Author

aseering commented Jul 1, 2016

strace emacs looks like a constant stream of:

...
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{"+\0\1\0", 4}, {NULL, 0}, {"", 0}], 3) = 4
poll([{fd=3, events=POLLIN}], 1, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\1\1]\n\0\0\0\0\22\0\200\0\0\0\0\0\1\0\0\0T\4\0\0\320\312\213\2\4\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(3, 0x7fffc79d9f30, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7fffc79d9f30, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7fffc79d9f40, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{"+\0\1\0", 4}, {NULL, 0}, {"", 0}], 3) = 4
poll([{fd=3, events=POLLIN}], 1, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\1\1^\n\0\0\0\0\22\0\200\0\0\0\0\0\1\0\0\0T\4\0\0\320\312\213\2\4\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(3, 0x7fffc79d9f00, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7fffc79d9f00, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{"+\0\1\0", 4}, {NULL, 0}, {"", 0}], 3) = 4
poll([{fd=3, events=POLLIN}], 1, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\1\1_\n\0\0\0\0\22\0\200\0\0\0\0\0\1\0\0\0T\4\0\0\320\312\213\2\4\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(3, 0x7fffc79d9f30, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7fffc79d9f30, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7fffc79d9f40, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}])
...

being dumped out about as quickly as I would expect the Windows Console to be able to render it.

@aseering
Copy link
Contributor Author

aseering commented Jul 1, 2016

Interestingly, if I open up a WSL terminal and do ssh -X real-ubuntu-1404-server, then run emacs remotely, it shows up correctly in Windows/Xming, and the application is responsive.

In this setup, strace ssh looks a lot like:

...
select(10, [3 4 7 8 9], [], NULL, NULL) = 1 (in [3])
clock_gettime(CLOCK_MONOTONIC, {97174, 557010000}) = 0
read(3, "\0\0\5\360\7<\7\270\374\301\r\215\215D\331\272\363\326o\203N\0173\233\355F?\31=\36\313|"..., 8192) = 1592
clock_gettime(CLOCK_MONOTONIC, {97174, 559067000}) = 0
clock_gettime(CLOCK_MONOTONIC, {97174, 559545000}) = 0
select(10, [3 4 7 8 9], [8], NULL, NULL) = 1 (out [8])
clock_gettime(CLOCK_MONOTONIC, {97174, 561989000}) = 0
write(8, "=\0\4\0\27\0\200\0J\2\334\1\20\0\16\0\221\4\6\0\216\0\200\0\27\0\200\0G\0\0\0"..., 1508) = 1508
clock_gettime(CLOCK_MONOTONIC, {97174, 563682000}) = 0
clock_gettime(CLOCK_MONOTONIC, {97174, 564052000}) = 0
select(10, [3 4 7 8 9], [], NULL, NULL) = 1 (in [8])
clock_gettime(CLOCK_MONOTONIC, {97174, 566094000}) = 0
read(8, "\1\0018\7\0\0\0\0\22\0\200\0\0\0\0\0\0\0\0\0l\4\0\0\260\314\213\2\4\0\0\0", 16384) = 32
clock_gettime(CLOCK_MONOTONIC, {97174, 568366000}) = 0
clock_gettime(CLOCK_MONOTONIC, {97174, 569510000}) = 0
select(10, [3 4 7 8 9], [3], NULL, NULL) = 1 (out [3])
clock_gettime(CLOCK_MONOTONIC, {97174, 572291000}) = 0
write(3, "\0\0\0000\300\331}3>\31\331_iQ\200\336l+\340xj\331\245\334\3468{\23\202,\327\357"..., 68) = 68
..

And strace emacs looks like this:

...
poll([{fd=4, events=POLLIN}, {fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 3, 0) = 0 (Timeout)
pselect6(4, [3], [], NULL, {0, 342785043}, {NULL, 8}) = 0 (Timeout)
rt_sigprocmask(SIG_BLOCK, [WINCH IO], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH IO], NULL, 8) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{";\0\5\0\32\0\200\0\0\0\0\0\n\0\0\0\7\0\16\0\221\6\5\0@\0\200\0\0\0\0\0"..., 124}, {NULL, 0}, {"", 0}], 3) = 124
recvmsg(3, 0x7ffd8ade9600, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7ffd8ade9610, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7ffd8ade8f40, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=4, events=POLLIN}, {fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 3, 0) = 0 (Timeout)
pselect6(4, [3], [], NULL, {0, 497207317}, {NULL, 8}) = 0 (Timeout)
rt_sigprocmask(SIG_BLOCK, [WINCH IO], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH IO], NULL, 8) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{";\0\5\0C\0\200\0\0\0\0\0\n\0\0\0000\2\16\0\221\6\5\0@\0\200\0\0\0\0\0"..., 124}, {NULL, 0}, {"", 0}], 3) = 124
...

In this scenario, emacs is emitting syscalls considerably more slowly than it was when running locally. The server in question is slower. But I wonder whether perhaps some syscall is not causing its thread to de-schedule for as long as it would under Linux, resulting in some sort of starvation?

@aseering
Copy link
Contributor Author

aseering commented Jul 1, 2016

@xarthurx mentioned a somewhat similar problem in a comment on #187 , but with different symptoms. I wonder if this could be a race condition of some sort.

@aseering
Copy link
Contributor Author

aseering commented Jul 1, 2016

It's probably worth pointing out that command-line emacs works just fine. You can verify this by either un-setting the DISPLAY environment variable and running emacs, or running emacs -nw.

@redviper
Copy link

redviper commented Jul 1, 2016

This has, oddly, been fixed in emacs-25 pretest. I am using graphical emacs atm.

@aseering
Copy link
Contributor Author

aseering commented Jul 2, 2016

Thanks!

I can confirm that graphical emacs works for me with the "emacs-snapshot" package in the "ppa:ubuntu-elisp" PPA, which currently reports as "GNU Emacs 25.1.50.2".

@lateau
Copy link

lateau commented Jul 2, 2016

@aseering @redviper Do you guys have any problem with maximize emacs window? This is my problem emacs-snapshot with Xming. It doesn't refresh current frame fit to maximized window width & height.

capture

$ emacs -fs
$ emacs -mm
$ emacs -fh -fw

These doesn't work for me. Any ideas?

  • Surface book
  • Build 14379
  • Xming
  • emacs-snapshot on ppa:ubuntu-elisp

@aseering
Copy link
Contributor Author

aseering commented Jul 2, 2016

Oh, good point -- yes, I do have that problem now, with the new emacs version.

@lateau
Copy link

lateau commented Jul 2, 2016

I tried to run emacs with MobaXTerm. No luck on maximize window, but I think MobaXTerm is better than Xming on display images and more clear fonts.

Some of commands that related to widgets such like GTK does not work, so I guess emacs with some other GUI library would possibly work if it supported.

(menu-bar-mode 0) ;; no effect
(tool-bar-mode 0) ;; no effect too

emacs_on_mobaxterm
eww

@lateau
Copy link

lateau commented Jul 2, 2016

Frame paramters are not modifiable.

(frame-parameter (selected-frame) 'width) ;; Returns 80
(set-frame-parameter (selected-frame) 'width 300)
(frame-parameter (selected-frame) 'width) ;; Returns 80

;; Whole list of frame parameters
(frame-parameters)

@lateau
Copy link

lateau commented Jul 2, 2016

@aseering Would you try this? It seems like emacs's --geomerty option works. Menubar and toolbar does not appear but the frame extended properly.

$ emacs -g 185x53
  • Build 14379
  • emacs-snapshot(25.1.50.2) on ppa:ubunt-elisp
  • MobaXTerm Home Edition

emacs_with_geo_opts

Here's a strace log(constantly loop):

poll([{fd=7, events=POLLIN}, {fd=6, events=POLLIN}], 2, 0) = 0 (Timeout)
clock_gettime(CLOCK_REALTIME, {1467462336, 718280100}) = 0
clock_gettime(CLOCK_REALTIME, {1467462336, 720600500}) = 0
clock_gettime(CLOCK_REALTIME, {1467462336, 723383700}) = 0
clock_gettime(CLOCK_REALTIME, {1467462336, 724630900}) = 0
rt_sigprocmask(SIG_BLOCK, [WINCH IO], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH IO], NULL, 8) = 0
poll([{fd=6, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=6, revents=POLLOUT}])
writev(6, [{";\0\5\0i\0\200\0\0\0\0\0\10\0\34\1\10\0\21\0\212\6\5\0004\0\200\0\0\0\0\0"..., 144}, {NULL, 0}, {"", 0}], 3) = 144
recvmsg(6, 0x7fffd2800ae0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7fffd2800910, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLIN}, {fd=6, events=POLLIN}], 2, 0) = 0 (Timeout)
clock_gettime(CLOCK_REALTIME, {1467462336, 750162800}) = 0
pselect6(8, [6 7], [], NULL, {0, 460140400}, {NULL, 8}) = 0 (Timeout)
recvmsg(6, 0x7fffd2800400, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLIN}, {fd=6, events=POLLIN}], 2, 0) = 0 (Timeout)
clock_gettime(CLOCK_REALTIME, {1467462337, 219505000}) = 0
clock_gettime(CLOCK_REALTIME, {1467462337, 221883400}) = 0
clock_gettime(CLOCK_REALTIME, {1467462337, 224421200}) = 0
clock_gettime(CLOCK_REALTIME, {1467462337, 226127100}) = 0
rt_sigprocmask(SIG_BLOCK, [WINCH IO], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH IO], NULL, 8) = 0
poll([{fd=6, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=6, revents=POLLOUT}])
writev(6, [{";\0\5\0]\0\200\0\0\0\0\0\10\0\34\1\310\5\21\0\212\6\5\0004\0\200\0\0\0\0\0"..., 144}, {NULL, 0}, {"", 0}], 3) = 144
recvmsg(6, 0x7fffd2800ae0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7fffd2800910, 0)           = -1 EAGAIN (Resource temporarily unavailable)

@aseering
Copy link
Contributor Author

aseering commented Jul 2, 2016

@lateau -- yes, -g lets me start with a larger window size.

I don't see a continuous loop of strace output. I see a lot of output whenever I interact with the window in any way -- mouse is over the window, cursor is blinking, etc -- but that's what I would expect given that emacs is interacting with the screen (and over TCP, even) whenever those things happen.

@lateau
Copy link

lateau commented Jul 2, 2016

@aseering You're right. Launch emacs with -nbc -Q does not produce that continuous output. Thank you. Loop was my misunderstanding it's just cursor blinking event output.

@redviper
Copy link

redviper commented Jul 4, 2016

You can fix the resizing issue by compiling a Lucid version instead of GTK. The problem seems to be something with the GTK resizing code. Get emacs from the git repo (I recommend the GitHub mirror btw, Savannah is slow), and build with ./configure --with-x-toolkit=lucid

You can get all the dependencies worked out before hand too with apt-get build-dep emacs24-lucid.

@masari
Copy link

masari commented Jul 6, 2016

xemacs works fine (although I never use it on real Linux)

@redviper
Copy link

Recently I find that the yank for x-selection is broken. Is this happening for others also or have I messed up my WSL configuration?

@lateau
Copy link

lateau commented Jul 19, 2016

@redviper It works on my build but sometimes it causes freezing emacs.

@foopang
Copy link

foopang commented Jul 21, 2016

I have problem with pasting text into emacs from Windows, while copying text from emacs to windows is just fine. Any workaround?

@fehrin
Copy link

fehrin commented Aug 30, 2016

Where do i find the emacs-25 pretest package mentioned in this issue?

@lateau
Copy link

lateau commented Aug 31, 2016

@fehrin

sudo add-apt-repository ppa:ubuntu-elisp/ppa
sudo apt-get update

@VMatrix1900
Copy link

Seems it's fixed in Creator's update, follow the instructions on the link: https://www.reddit.com/r/bashonubuntuonwindows/comments/65dpjd/getting_xapplications_running_in_ubuntu_16041/

@therealkenc
Copy link
Collaborator

This circa 2016 issue is I think (?) fundamentally dupe #1609 (epoll wait doesn't). Even if the problem wasn't that issue specifically, there is a lot of select/poll water under the bridge since this issue was submitted. We'll call it fixedcreatorsupdate. If there are any outstanding issues with xemacs running on WSL that would not manifest in the same way when running remotely from Real Linux to Xming, VcXsrv, Windows Remote Desktop via xrdp (etc etc) do feel to break out a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants