Open hampsterx opened 11 years ago
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... :crying_cat_face:
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...
@deadprogram can you confirm this still impacts 0.15.0.pre
?
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
@deadprogram oof! do you have a repro for that?
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]
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"
I was referring to artoo tests not celluloid ones. I will open new issue
Entered separate issue here: https://github.com/celluloid/celluloid/issues/321
I will retest the Win7 issue in a bit as well...
OK confirm the Windows 7 problem in this issue still exists when testing 0.15.0.pre
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)
Have you tried running it with jruby? Its usually working better on Windows for me.
@mechanicalduck can you post a backtrace?
Can you try celluloid-io --pre ? (0.16.0.pre2)
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
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
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.
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.
JRuby should be able to do it without any native code: https://blogs.oracle.com/thejavatutorials/entry/watching_a_directory_for_changes
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?
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? :wink:
@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.
@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 :wink:
As for Windows testing, I'm working out ways to automate testing for Ruby using AppVeyor:
Of course that will not solve manual hacking but is a start :grin:
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.
Reproducing the deadlock issue:
cd C:\DevKit
C:\DevKit>ruby dk.rb init
C:\DevKit>ruby dk.rb install( --force)
C:\DevKit>devkitvars.bat
gem install listen thor celluloid-io wdm --verbose --no-ri --no-rdoc
listen --forward <ip-address>:4000
telnet <ip-address-of-listen-gem-running-host> 4000
Side Note: You can always terminate the telnet session with Ctrl - (if you got stuck).
With best regards
+1
+1
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'
...
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:
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'