Has anyone tried out drb on latest ruby1.9 including VM? Well, I tried
out drb and found that DRb#start_service won’t return on YARV as it
does on Ruby1.8. It is so strange that I can not find a reasonable
explanation for the behaviour.
Let me explain what I found out by (manually) tracing the threads of
execution in drb:
The main thread enters DRbServer#initialize and enters DRbServer#run.
In run a new thread (the main_loop of the DRBServer) is startet that
runs concurrently until it blocks in Socket#accept. The strange thing
is, that exactly after the main_loop thread begins to block the main
thread won’t run any further! Right before the end of
DRbServer#initialize it stops and does not jump out though there is
nothing left to do.
Next thing I tried is replacing the Socket#accept by something else. I
replaced it by a sleep( 5). With this the main thread is able to jump
out of DRbServer#initialize … suggesting that the bug lies in
Socket#accept. However I made up a simple test script with a socket
and put the line socket.accept in a thread. This test script runs as
it should on both yarv and on 1.8.5 without blocking the main thread.
I’m sorry, that I was not yet able to reproduce the freeze in a
minimal test script.
I’d say it smells like a deadlock but I am definitely not a threading
expert and I don’t know much about Sockets and the internals of YARV
so I leave the interpretation of the facts to the experts among you.