WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Thin (ruby EM based server)

Open ddfznt opened this issue 10 years ago • 14 comments

see this gist.


clock_gettime(CLOCK_REALTIME, {1465583395, 663255600}) = 0
clock_gettime(CLOCK_REALTIME, {1465583395, 663347200}) = 0
clock_gettime(CLOCK_REALTIME, {1465583395, 663443500}) = 0
clock_gettime(CLOCK_REALTIME, {1465583395, 663546800}) = 0
times({tms_utime=1014, tms_stime=1579, tms_cutime=6, tms_cstime=15}) = 50171
clock_gettime(CLOCK_REALTIME, {1465583395, 663875500}) = 0
read(17, 0x7fffe278d430, 16384)         = -1 EAGAIN (Resource temporarily unavailable)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe27914a0) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791450) = -1 EINVAL (Invalid argument)
select(19, [12 14 16 17 18], [17], [], {0, 0}) = 2 (in [16], out [17], left {0, 0})
read(16, "", 16384)                     = 0
writev(17, [{"HTTP/1.1 200 OK\r\nX-Frame-Options"..., 354}, {"<!DOCTYPE html>\n<html>\n<head>\n  "..., 1908}], 2) = 2262
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_MONOTONIC_RAW, 0x7fffe2791420) = -1 EINVAL (Invalid argument)

(forever)

ddfznt avatar Jun 10 '16 19:06 ddfznt

Thanks for reporting this and the strace (very helpful). CLOCK_MONOTONIC_RAW is currently not implemented in WSL. I have opened a bug to track this, but unfortunately it won't make the cut for Anniversary update. Can you please share precise repro steps?

sunilmut avatar Jun 15 '16 20:06 sunilmut

Just a new rails application with "thin" gem.

#(install ruby, rails... )

rails new app
cd app
echo "gem 'thin'" >> Gemfile
bundle install 
thin start

#=> Booting Thin...

ddfznt avatar Jun 15 '16 20:06 ddfznt

FWIW: I just installed RoR on Debian and ran into this issue. Right after the first page access Ruby runs into this loop and only eventually calms down (almost never, though).

thomaskilian avatar Jul 04 '16 10:07 thomaskilian

I've created an issue specific to the clock_gettime issue. So this might also help in fixing this problem: https://github.com/Microsoft/BashOnWindows/issues/1023

gergap avatar Aug 31 '16 11:08 gergap

Hi, I'm the maintainer of the Ruby EventMachine. It should not be using CLOCK_MONOTONIC_RAW on Windows, and does not need it to be available. I wrote a very cross-platform clock wrapper here:

https://github.com/eventmachine/eventmachine/blob/master/ext/em.cpp#L440

Is there something about the BashOnWindows toolkit that is making EM think that CLOCK_MONOTONIC_RAW is defined even though it's not actually available from the system?

Could you post the gem install --verbose eventmachine output that you get? I expect to see something like this:

...
checking for windows.h... yes
checking for winsock.h... yes
checking for main() in -lkernel32... yes
checking for main() in -lrpcrt4... yes
checking for main() in -lgdi32... yes
checking for getaddrinfo()... yes
checking for clock_gettime()... yes
checking for CLOCK_MONOTONIC_RAW in time.h... no
checking for CLOCK_MONOTINIC in time.h... yes
...

The important part is that CLOCK_MONOTONIC_RAW is not found in time.h, and so EM won't try to use it. A possible bug is if BashOnWindows defines this constant but it's not available from the system?

sodabrew avatar Dec 27 '16 17:12 sodabrew

Hey @sodabrew, thanks for checking out this issue! Not to worry, it's not your fault it's broken, your clock wrapper works great when it's not being lied to.

It's very important to remember that this repository is actually about the Windows Subsystem for Linux, in which Microsoft has reimplemented the Linux kernel ABI, in much the same way that Illumos has lx-branded zones, so Linux binaries can run on a Windows 10 system with the WSL installed without knowing the secret that this is on Windows.

As such, the relevant snippet of the output of the extconf.rb stage of installing the eventmachine gem looks like this:

...
checking for epoll_create() in sys/epoll.h... yes
checking for clock_gettime()... yes
checking for CLOCK_MONOTONIC_RAW in time.h... yes
checking for CLOCK_MONOTONIC in time.h... yes
...

It is definitely an issue that CLOCK_MONOTONIC_RAW is defined in time.h (considering that it's the same time.h you'd find on a normal install of Ubuntu 16.04), but it is not actually implemented in WSL.

onekopaka avatar Dec 27 '16 22:12 onekopaka

Aha! Yes! You'll need to fix that implementation fib then :)

sodabrew avatar Dec 27 '16 23:12 sodabrew

Closing this issue as it's stale. Bug us if you can repro.

tara-raj avatar May 22 '18 21:05 tara-raj

@tara-raj Did you fix it?

sodabrew avatar May 22 '18 21:05 sodabrew

I went through a chain of issues all of which say they are duplicates of others and eventually ended up here, where the issue is closed as stale, but it's very much still reproducable in modern builds. Can it be reopened please?

RReverser avatar Dec 12 '18 13:12 RReverser

Thanks. Reopening.

therealkenc avatar Dec 12 '18 22:12 therealkenc

Hmm, looking at original issue again, I'm starting to suspect that it's not actually the same although likely related to current. Let me recheck and provide more details here tomorrow.

RReverser avatar Dec 12 '18 22:12 RReverser

Right. I just found a comment at the bottom of #77 indicating CLOCK_MONOTONIC_RAW was implemented. I had assumed it wasn't. No word in the release notes and no answer to "did you fix it", in May, either (sigh).

Related or not, better to spawn a new issue with a disciplined repro.

therealkenc avatar Dec 12 '18 22:12 therealkenc

Yeah, fair enough. Thanks for chasing this.

RReverser avatar Dec 12 '18 23:12 RReverser