Deadlock in borges sample apps

L

Lloyd Zusman

I have installed borges-1.1.0, and I'm using it with the following
version of ruby:

% ruby --version
ruby 1.9.0 (2004-08-03) [i386-freebsd4.0]

The first thing I did after installation was to run this test app, as
described in the README file (note that I changed "1.8" to "1.9"):

ruby /usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb

I then went to my browser and entered the following URL, again as
specified in the README file:

http://localhost:7000/borges/counter

The following message came back to my web browser:

Internal Server Error
deadlock; recursive locking
WEBrick/1.3.1 (Ruby/1.9.0/2004-08-03) at localhost:7000

The borges process that I started printed the information at the bottom
of this message.

Note that I got the same "recursive locking" deadlock with the sample
SushiNet application.

Is borges-1.1.0 incompatible with ruby 1.9, perhaps?

Here's the output from borges:

[2004-11-26 18:55:06] INFO WEBrick 1.3.1
[2004-11-26 18:55:06] INFO ruby 1.9.0 (2004-08-03) [i386-freebsd4.0]
[2004-11-26 18:55:06] INFO WEBrick::HTTPServer#start: pid=35885 port=7000
!!
Exception in #<Thread:0x81f5d48 run>:
deadlock; recursive locking
/usr/local/lib/ruby/1.9/thread.rb:96:in `lock'
/usr/local/lib/ruby/1.9/thread.rb:132:in `synchronize'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:136:in `start_handler_thread'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:135:in `loop'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:135:in `start_handler_thread'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:127:in `start'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:127:in `start_handler_thread'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:163:in `in_thread'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:92:in `enter_session'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:105:in `enter_session_with'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Application.rb:7:in `handle_default_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Registry.rb:37:in `handle_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Dispatcher.rb:39:in `handle_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:35:in `do_GET'
/usr/local/lib/ruby/1.9/webrick/httpservlet/abstract.rb:35:in `__send__'
/usr/local/lib/ruby/1.9/webrick/httpservlet/abstract.rb:35:in `service'
/usr/local/lib/ruby/1.9/webrick/httpserver.rb:101:in `service'
/usr/local/lib/ruby/1.9/webrick/httpserver.rb:62:in `run'
/usr/local/lib/ruby/1.9/webrick/server.rb:153:in `start_thread'
/usr/local/lib/ruby/1.9/webrick/server.rb:147:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:147:in `start_thread'
/usr/local/lib/ruby/1.9/webrick/server.rb:97:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:89:in `each'
/usr/local/lib/ruby/1.9/webrick/server.rb:89:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:79:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:79:in `start'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:79:in `start'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:85
!!
/usr/local/lib/ruby/1.9/thread.rb:96:in `lock'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:171:in `in_thread'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:165:in `synchronize'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:165:in `in_thread'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:92:in `enter_session'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:105:in `enter_session_with'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Application.rb:7:in `handle_default_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Registry.rb:37:in `handle_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Dispatcher.rb:39:in `handle_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:35:in `do_GET'
/usr/local/lib/ruby/1.9/webrick/httpservlet/abstract.rb:35:in `__send__'
/usr/local/lib/ruby/1.9/webrick/httpservlet/abstract.rb:35:in `service'
/usr/local/lib/ruby/1.9/webrick/httpserver.rb:101:in `service'
/usr/local/lib/ruby/1.9/webrick/httpserver.rb:62:in `run'
/usr/local/lib/ruby/1.9/webrick/server.rb:153:in `start_thread'
/usr/local/lib/ruby/1.9/webrick/server.rb:147:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:147:in `start_thread'
/usr/local/lib/ruby/1.9/webrick/server.rb:97:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:89:in `each'
/usr/local/lib/ruby/1.9/webrick/server.rb:89:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:79:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:79:in `start'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:79:in `start'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:85
!!
[2004-11-26 18:55:14] ERROR ThreadError: deadlock; recursive locking
/usr/local/lib/ruby/1.9/thread.rb:96:in `lock'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:171:in `in_thread'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:165:in `synchronize'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:165:in `in_thread'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:92:in `enter_session'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Session.rb:105:in `enter_session_with'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Application.rb:7:in `handle_default_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Registry.rb:37:in `handle_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler/Dispatcher.rb:39:in `handle_request'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:35:in `do_GET'
/usr/local/lib/ruby/1.9/webrick/httpservlet/abstract.rb:35:in `__send__'
/usr/local/lib/ruby/1.9/webrick/httpservlet/abstract.rb:35:in `service'
/usr/local/lib/ruby/1.9/webrick/httpserver.rb:101:in `service'
/usr/local/lib/ruby/1.9/webrick/httpserver.rb:62:in `run'
/usr/local/lib/ruby/1.9/webrick/server.rb:153:in `start_thread'
/usr/local/lib/ruby/1.9/webrick/server.rb:147:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:147:in `start_thread'
/usr/local/lib/ruby/1.9/webrick/server.rb:97:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:89:in `each'
/usr/local/lib/ruby/1.9/webrick/server.rb:89:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:79:in `start'
/usr/local/lib/ruby/1.9/webrick/server.rb:79:in `start'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:79:in `start'
/usr/local/lib/ruby/site_ruby/1.9/Borges/WEBrick.rb:85

home.acholado.net - - [26/Nov/2004:18:55:14 EST] "GET /borges/counter HTTP/1.1" 500 312
- -> /borges/counter
[2004-11-26 18:55:14] ERROR `/favicon.ico' not found.
home.acholado.net - - [26/Nov/2004:18:55:14 EST] "GET /favicon.ico HTTP/1.1" 404 286
- -> /favicon.ico
 
L

Lloyd Zusman

Kaspar Schiess said:
Hello Lloyd,

Currently, the answer to that question is sadly YES. There is some code in
Session.rb that is incompatible with Ruby 1.9, and frankly, also with my
perception of how things should be done in 1.8. I have a private patched
version that uses modern synchronisation elements instead of on the spot
hacks, and that version should work with Ruby 1.9. I will attach that to
this post (making it a public patch); I just did not think anyone would
actually currently use Borges, that is why its not in CVS.

Tell me if this works for you, that might inspire me to actually check this
in. Note that I use Borges frequently and still think that it kicks ass.

Thank you very much.

However, I'm sorry to report that the version of Session.rb that you
sent is exactly the same version that got installed in

/usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler

I did the following:

- invoke this:

% cd /usr/local/lib/ruby/site_ruby/1.9/Borges/RequestHandler

- copy Session.rb.gz from this message into that directory

- invoke this:

% mv Session.rb Session.rb.orig
% gunzip Session.rb.gz
% diff -b Session.rb.orig Session.rb
%

In other words, there was no output from the 'diff'. This means that
aside from differences in white space, the Session.rb.gz that you
attached, when uncompressed, is exactly the same as the version that got
installed from the borges tarball.

Are you sure that you attached the correct version of Session.rb.gz to
your message?
 
L

Lloyd Zusman

Kaspar Schiess said:
You have prooven quite conclusivly that it was the wrong one. Since there
is no other one lying around here, that means the patch has been lost. I
had to redevelop it, so here you have my completely fresh code as a diff -c
patch (attachment).

This new patch works perfectly with both the counter and the SushiNet
apps! I haven't tested it with anything else yet, however.

Sorry for having wasted your time.
kaspar

Not a waste of time at all ... this is what software and debugging is
all about. I'm just very grateful that you took the time to recreate
the patch.

Thank you very much!

 
K

Kaspar Schiess

Hello Lloyd,
Not a waste of time at all ... this is what software and debugging is
all about. I'm just very grateful that you took the time to recreate
the patch.

Good that it works. Just a word of warning, I am not sure about the
exception handler that does

cur_thr.kill
@Thread = nil

especially that last line is dangerous and insufficient. It will probably
never get executed, so that solves the problem. It should probably go
something like this:

@Thread[:abort_with_error] = true
cur_thr.kill

And someone would have to check for that.

This popped into my head last night, for what its worth...

yours truly,
kaspar

hand manufactured code - www.tua.ch/ruby
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top