Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

win7/32 - busted running EchoServer example #74

Open
hampsterx opened this issue Jul 3, 2013 · 27 comments
Open

win7/32 - busted running EchoServer example #74

hampsterx opened this issue Jul 3, 2013 · 27 comments
Milestone

Comments

@hampsterx
Copy link

starts fine but when I connect to it, it crashes..
Also tested code on Ubuntu, works fine..

any ideas...

E, [2013-07-04T10:35:42.466017 #3800] ERROR -- : EchoServer crashed!
ThreadError: deadlock; recursive locking
internal:prelude:8:in lock' <internal:prelude>:8:insynchronize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/nio4r-0.4.6/lib/nio/selector.rb:34:i
n deregister' C:/Ruby193/lib/ruby/gems/1.9.1/gems/nio4r-0.4.6/lib/nio/monitor.rb:40:in close'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-io-0.14.1/lib/celluloid/io
/reactor.rb:51:in block in run_once' C:/Ruby193/lib/ruby/gems/1.9.1/gems/nio4r-0.4.6/lib/nio/selector.rb:88:i nblock (2 levels) in select'
C:/Ruby193/lib/ruby/1.9.1/set.rb:222:in block in each' C:/Ruby193/lib/ruby/1.9.1/set.rb:222:ineach_key'
C:/Ruby193/lib/ruby/1.9.1/set.rb:222:in each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/nio4r-0.4.6/lib/nio/selector.rb:87:i nblock in select'
internal:prelude:10:in synchronize' C:/Ruby193/lib/ruby/gems/1.9.1/gems/nio4r-0.4.6/lib/nio/selector.rb:48:i nselect'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-io-0.14.1/lib/celluloid/io
/reactor.rb:49:in run_once' C:/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/event ed_mailbox.rb:56:inreceive'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/actor
.rb:173:in run' C:/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/actor .rb:157:inblock in initialize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/threa
d_handle.rb:13:in block in initialize' C:/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/inter nal_pool.rb:59:incall'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/inter
nal_pool.rb:59:in `block in create'

@deadprogram
Copy link

This same problem currently exists with celluloid 0.14.1 on Win7/x64, with nio4r v0.5.0. Seems like perhaps it impacts any Windows users wanting to use celluloid-io... 😿

@deadprogram
Copy link

Here is some my resulting backtrace:

ThreadError: deadlock; recursive locking
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-0.5.0/lib/nio/selector.rb:
38:in `synchronize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-0.5.0/lib/nio/selector.rb:
38:in `deregister'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-0.5.0/lib/nio/monitor.rb:4
0:in `close'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.14.1/lib/celluloi
d/io/reactor.rb:51:in `block in run_once'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-0.5.0/lib/nio/selector.rb:
92:in `block (2 levels) in select'
        C:/Ruby200-x64/lib/ruby/2.0.0/set.rb:232:in `each_key'
        C:/Ruby200-x64/lib/ruby/2.0.0/set.rb:232:in `each'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-0.5.0/lib/nio/selector.rb:
91:in `block in select'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-0.5.0/lib/nio/selector.rb:
52:in `synchronize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-0.5.0/lib/nio/selector.rb:
52:in `select'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.14.1/lib/celluloi
d/io/reactor.rb:49:in `run_once'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.14.1/lib/celluloid/e
vented_mailbox.rb:56:in `receive'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.14.1/lib/celluloid/a
ctor.rb:173:in `run'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.14.1/lib/celluloid/a
ctor.rb:157:in `block in initialize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.14.1/lib/celluloid/t
hread_handle.rb:13:in `block in initialize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.14.1/lib/celluloid/i
nternal_pool.rb:59:in `call'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.14.1/lib/celluloid/i
nternal_pool.rb:59:in `block in create'
E, [2013-08-24T19:35:32.314075 #904] ERROR -- : ["C:/Ruby200-x64/lib/ruby/gems/2
.0.0/gems/celluloid-0.14.1/lib/celluloid/tasks.rb:61:in `suspend'", "C:/Ruby200-
x64/lib/ruby/gems/2.0.0/gems/celluloid-0.14.1/lib/celluloid/tasks.rb:19:in `susp
end'", "C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.14.1/lib/celluloi
d/io/reactor.rb:44:in `wait'", "C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloi
d-io-0.14.1/lib/celluloid/io/reactor.rb:26:in `wait_writable'", "C:/Ruby200-x64/
lib/ruby/gems/2.0.0/gems/celluloid-io-0.14.1/lib/celluloid/io.rb:47:in `wait_wri
table'", "C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.14.1/lib/cellul
oid/io/stream.rb:36:in `wait_writable'", "C:/Ruby200-x64/lib/ruby/gems/2.0.0/gem
s/celluloid-io-0.14.1/lib/celluloid/io/tcp_socket.rb:87:in `rescue in initialize
'", "C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.14.1/lib/celluloid/i
o/tcp_socket.rb:84:in `initialize'", "C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/ar...

@tarcieri
Copy link
Member

@deadprogram can you confirm this still impacts 0.15.0.pre?

@deadprogram
Copy link

This might be a dumb question, why are my unit tests now erroring with the following when running using 0.15.0.pre?

Celluloid::Error: Thread pool is not running

@tarcieri
Copy link
Member

@deadprogram oof! do you have a repro for that?

@deadprogram
Copy link

This is on running tests on https://github.com/hybridgroup/artoo/tree/celluloid-0.15.0.pre by running

bundle install
bundle exec rake test

I am using the following Ruby when running tests:

$ ruby -v
rubinius 2.0.0.rc1 (1.9.3 c5bc086c yyyy-mm-dd JI) [x86_64-unknown-linux-gnu]

@tarcieri
Copy link
Member

Hmm, maybe you can try opening another issue for this so we don't clutter the conversation here. That said, you need to run "rake spec", not "rake test"

@deadprogram
Copy link

I was referring to artoo tests not celluloid ones. I will open new issue

@deadprogram
Copy link

Entered separate issue here: celluloid/celluloid#321

I will retest the Win7 issue in a bit as well...

@deadprogram
Copy link

OK confirm the Windows 7 problem in this issue still exists when testing 0.15.0.pre

@mechanicalduck
Copy link

Confirmed that it fails the same way on Windows 7, also on x64.

I am using guard/listen which uses celluloid-io and cannot be used because of this issue.

(Issue pushed/voted up)

@Asmod4n
Copy link
Contributor

Asmod4n commented Aug 1, 2014

Have you tried running it with jruby? Its usually working better on Windows for me.

@tarcieri
Copy link
Member

tarcieri commented Aug 1, 2014

@mechanicalduck can you post a backtrace?

Can you try celluloid-io --pre ? (0.16.0.pre2)

@mechanicalduck
Copy link

Thank you for your quick responses!

@Asmod4n:
I got this issue using Ruby from
RubyInstaller (http://rubyinstaller.org/downloads/) (Ruby 2.0.0-p481 (x64)).

@tarcieri:
Backtrace (still using the stable celluloid-io):

E, [2014-08-01T20:35:56.422629 #30504] ERROR -- : Listen::TCP::Broadcaster crashed!
ThreadError: deadlock; recursive locking
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:38:in `synchronize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:38:in `deregister'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/monitor.rb:40:in `close'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.15.0/lib/celluloid/io/reactor.rb:51:in `block in run_once'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:92:in `block (2 levels) in select'
        C:/Ruby200-x64/lib/ruby/2.0.0/set.rb:232:in `each_key'
        C:/Ruby200-x64/lib/ruby/2.0.0/set.rb:232:in `each'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:91:in `block in select'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:52:in `synchronize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:52:in `select'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.15.0/lib/celluloid/io/reactor.rb:49:in `run_once'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.15.2/lib/celluloid/evented_mailbox.rb:53:in `receive'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:173:in `run'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:157:in `block in initialize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.15.2/lib/celluloid/thread_handle.rb:13:in `block in initialize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `call'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `block in create'

If interesting: This error occurs in the moment a peer connects to guard/listen.

I will install celluloid-io --pre (0.16.0.pre2) as advised and check if the issue still occurs then.

With best regards

@mechanicalduck
Copy link

Issue still persists after upgrading to celluloid-io --pre (0.16.0.pre2):

E, [2014-08-01T20:48:11.702685 #25208] ERROR -- : Broadcaster.run: #<ThreadError: deadlock; recursive locking>:C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:38:in `synchronize'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:38:in `deregister'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/monitor.rb:40:in `close'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:86:in `reregister'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:80:in `wait'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:70:in `wait_readable'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:23:in `block in wait_readable'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:52:in `wait'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:22:in `wait_readable'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io.rb:53:in `wait_readable'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/tcp_server.rb:15:in `accept'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/listen-2.7.9/lib/listen/tcp/broadcaster.rb:50:in `run'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/calls.rb:26:in `public_send'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/calls.rb:26:in `dispatch'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/calls.rb:122:in `dispatch'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/cell.rb:60:in `block in invoke'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/cell.rb:71:in `block in task'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/actor.rb:357:in `block in task'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/tasks.rb:57:in `block in initialize'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'
E, [2014-08-01T20:48:11.705685 #25208] ERROR -- : Actor crashed!
ThreadError: deadlock; recursive locking
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:38:in `synchronize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/selector.rb:38:in `deregister'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nio4r-1.0.0/lib/nio/monitor.rb:40:in `close'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:86:in `reregister'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:80:in `wait'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:70:in `wait_readable'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:23:in `block in wait_readable'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:52:in `wait'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/reactor.rb:22:in `wait_readable'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io.rb:53:in `wait_readable'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.0.pre2/lib/celluloid/io/tcp_server.rb:15:in `accept'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/listen-2.7.9/lib/listen/tcp/broadcaster.rb:50:in `run'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/calls.rb:26:in `public_send'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/calls.rb:26:in `dispatch'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/calls.rb:122:in `dispatch'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/cell.rb:60:in `block in invoke'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/cell.rb:71:in `block in task'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/actor.rb:357:in `block in task'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/tasks.rb:57:in `block in initialize'
        C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/celluloid-0.16.0.pre3/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'

With best regards

@tarcieri
Copy link
Member

tarcieri commented Aug 2, 2014

There's an open question as to why Windows is causing reentrant locking here.

I know nio4r's locking model is kind of shitty. Perhaps it needs to be revisited.

Perhaps you should push guard upstream not to use Celluloid::IO until this issue is hammered out on Windows? They're not getting a whole lot of benefit from it at the moment, IMO.

@mechanicalduck
Copy link

I will post a ticket and proposing to replace Celluloid::IO with native code.

@Asmod4n
On JRuby 1.7.13 (Ruby 2.x) on the same Windows system this issue doesn't occur.

However, JRuby doesn't support building gem native extensions anymore.
This means that guard/listen has to poll which actually defeats the whole purpose
of running it on the system which faces the files locally for kernel-supported monitoring.

@Asmod4n
Copy link
Contributor

Asmod4n commented Aug 2, 2014

JRuby should be able to do it without any native code: https://blogs.oracle.com/thejavatutorials/entry/watching_a_directory_for_changes

@mechanicalduck
Copy link

So Java natively supports file system notification handling.

For using this in guard/listen I would probably have to rewrite the source code
to replace gem wdm with native Java or add an exception, in gem wdm itself, for separate handling on JRuby environments?

@tarcieri
Copy link
Member

tarcieri commented Aug 2, 2014

It would be nice to get filesystem monitoring added to nio4r in a cross-platform way.

re: this particular bug, I don't have access to a Windows machine or any way to debug it, sorry.

@luislavena I don't suppose you have any ideas? 😉

@Asmod4n
Copy link
Contributor

Asmod4n commented Aug 2, 2014

@mechanicalduck it sounds more like listen could use a java "adapter". Or like @tarcieri said a cross platform way for nio4r to handle it.

It's currently a mess to handle file system events in ruby, while libev has ways to do it nicely it has zero windows support afaik, libuv on the other hand has windows support, at least for sockets, dunno for file events.

@luislavena
Copy link

@tarcieri hello there.

I remember (a year ago) when suggested migrate nio4r C interface to use libuv, which actually have cross-platform watch functionality for file/directory events 😉

As for Windows testing, I'm working out ways to automate testing for Ruby using AppVeyor:

http://www.appveyor.com/

Of course that will not solve manual hacking but is a start 😁


Will take a look and attempt to investigate the deadlock issue. If you folks can provide a simple scenario for me to reproduce, will be great.

@mechanicalduck
Copy link

Reproducing the deadlock issue:

cd C:\DevKit
C:\DevKit>ruby dk.rb init
C:\DevKit>ruby dk.rb install( --force)
C:\DevKit>devkitvars.bat
  • Install listen gem and dependencies (notably celluloid-io):
gem install listen thor celluloid-io wdm --verbose --no-ri --no-rdoc
  • Start listen gem in tcp forwarding mode:
listen --forward <ip-address>:4000
  • Open a telnet client session (Windows 7 unfortunately haven't got a telnet client anymore,
    obtain a telnet client program or use a Linux client with telnet for example).
    Connect to the ip address the gem listen listens on with correct port:
telnet <ip-address-of-listen-gem-running-host> 4000

Side Note: You can always terminate the telnet session with Ctrl - (if you got stuck).

  • Crash should happen immediately, telnet session is disconnected by host,
    error and backtrace printed on the host on the cmd where the gem ran.

With best regards

@noinkling
Copy link

+1

1 similar comment
@mechanicalduck
Copy link

+1

@ccoenen
Copy link

ccoenen commented Oct 9, 2014

same problem here. Win8 / Ruby 2.0.0-481 32bit / celluloid 0.16.0 / celluloid-io 0.16.1

ThreadError: deadlock; recursive locking
    C:/Tools/Ruby200/lib/ruby/gems/2.0.0/gems/nio4r-1.0.1/lib/nio/selector.rb:40:in `synchronize'
    C:/Tools/Ruby200/lib/ruby/gems/2.0.0/gems/nio4r-1.0.1/lib/nio/selector.rb:40:in `deregister'
    C:/Tools/Ruby200/lib/ruby/gems/2.0.0/gems/nio4r-1.0.1/lib/nio/monitor.rb:40:in `close'
    C:/Tools/Ruby200/lib/ruby/gems/2.0.0/gems/celluloid-io-0.16.1/lib/celluloid/io/reactor.rb:51:in `block in run_once'
    ...

@ccoenen
Copy link

ccoenen commented Nov 5, 2014

Just ran into the exact same problem again. Found my own "me too" above, giggled, shook my head, left this message.

Dear future self: if you find this again and don't remember: you're weird.
Also: you made a nice, short gist in the past (my present), that reproduces your error nicely:

https://gist.github.com/ccoenen/7d39c37d72d4c2a5df1d

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

No branches or pull requests

9 participants