List Info

Thread: reproducible bug in DRb on OSX




reproducible bug in DRb on OSX
user name
2006-05-16 19:25:18
I've been tearing my hair out the last few days trying to
track down  
a bug in a gem that turns out to live in DRb. The gem is
'reliable- 
msg' and it relies on DRb for rpc (I've cc'ed the author
too).

I am not a good enough rubyist to track the problem all the
way to  
its true source, but I do have a simple test case to
reproduce the  
bug. Plus, there's a simple work around (look at the
comments in the  
server sample code).

As near as I can tell, this only breaks on OSX (OSX 10.4.6,
ruby  
1.8.4, DRb 2.0.4).

The error concerns ACL handling and how 127.0.0.1/localhost
is  
interpreted (maybe an ipv6 prob?). Doing a 'netstat
-an|grep 9000'  
while the following code is run shows:
tcp6       0      0  ::1.9000               *.*             
       
LISTEN

With apologies to Eric Hodel from whom I borrowed some code,
here are  
the samples:

------ SERVER --------
#!/usr/bin/env ruby -w
# simple_service.rb
# A simple DRb service

# load DRb
require 'drb'
require 'drb/acl'

# start up the DRb service
DRb.start_service   'druby://localhost:9000',
                     [],
                     :tcp_acl => ACL.new('allow
127.0.0.1'.split("  
"), ACL::ALLOW_DENY) # <-- causes failure
                     #:tcp_acl => ACL.new('allow
localhost'.split("  
"), ACL::ALLOW_DENY)  <-- works
                     # works if you replace 127.0.0.1 with
localhost

# wait for the DRb service to finish before exiting
DRb.thread.join
-------------

--------- CLIENT ---------
#!/usr/bin/env ruby -w
# simple_client.rb
# A simple DRb client

require 'drb'

# attach to the DRb server
remote_array = DRbObject.new nil,
                              'druby://localhost:9000'

puts remote_array.size

remote_array << 1

puts remote_array.size
-------------

The error displayed by the client is:

~/developer/projects/ruby/bugs/drb-acl cremes$ ruby -w  
simple_client.rb druby://localhost:9000
/opt/local/lib/ruby/1.8/drb/drb.rb:567:in `load':
connection closed  
(DRb:RbConnEr
ror)
         from /opt/local/lib/ruby/1.8/drb/drb.rb:629:in
`recv_reply'
         from /opt/local/lib/ruby/1.8/drb/drb.rb:918:in
`recv_reply'
         from /opt/local/lib/ruby/1.8/drb/drb.rb:1192:in
`send_message'
         from /opt/local/lib/ruby/1.8/drb/drb.rb:1083:in  
`method_missing'
         from /opt/local/lib/ruby/1.8/drb/drb.rb:1167:in
`open'
         from /opt/local/lib/ruby/1.8/drb/drb.rb:1082:in  
`method_missing'
         from /opt/local/lib/ruby/1.8/drb/drb.rb:1100:in
`with_friend'
         from /opt/local/lib/ruby/1.8/drb/drb.rb:1081:in  
`method_missing'
         from simple_client.rb:13

reproducible bug in DRb on OSX
user name
2006-05-16 22:57:37
On May 16, 2006, at 12:25 PM, cremes.devlistmac.com
wrote:

> I've been tearing my hair out the last few days trying
to track  
> down a bug in a gem that turns out to live in DRb. The
gem is  
> 'reliable-msg' and it relies on DRb for rpc (I've
cc'ed the author  
> too).
>
> I am not a good enough rubyist to track the problem all
the way to  
> its true source, but I do have a simple test case to
reproduce the  
> bug. Plus, there's a simple work around (look at the
comments in  
> the server sample code).
>
> As near as I can tell, this only breaks on OSX (OSX
10.4.6, ruby  
> 1.8.4, DRb 2.0.4).
>
> The error concerns ACL handling and how
127.0.0.1/localhost is  
> interpreted (maybe an ipv6 prob?). Doing a 'netstat
-an|grep 9000'  
> while the following code is run shows:
> tcp6       0      0  ::1.9000               *.*        
            
> LISTEN

IPv6 can be the bane of your existence.  Setting up proper
name  
service for it is not fun.

If you're only going to be talking over loopback you may
want to  
switch to UNIX sockets.

> With apologies to Eric Hodel from whom I borrowed some
code, here  
> are the samples:
>
> ------ SERVER --------
> #!/usr/bin/env ruby -w
> # simple_service.rb
> # A simple DRb service
>
> # load DRb
> require 'drb'
> require 'drb/acl'
>
> # start up the DRb service
> DRb.start_service   'druby://localhost:9000',

You can change this to 'druby://127.0.0.1:9000', that will
force it  
to use IPv4.

>                     [],
>                     :tcp_acl => ACL.new('allow
127.0.0.1'.split("  
> "), ACL::ALLOW_DENY) # <-- causes failure
>                     #:tcp_acl => ACL.new('allow
localhost'.split("  
> "), ACL::ALLOW_DENY)  <-- works
>                     # works if you replace 127.0.0.1
with localhost

DRb chose to listen on the IPv6 socket, so you'll need to
allow both  
127.0.0.1 and ::1 or just use localhost.

You could also try removing ::1 localhost from /etc/hosts,
that might  
fix it.

> # wait for the DRb service to finish before exiting
> DRb.thread.join
> -------------
>
> The error displayed by the client is:
>
> ~/developer/projects/ruby/bugs/drb-acl cremes$ ruby -w 

> simple_client.rb druby://localhost:9000
> /opt/local/lib/ruby/1.8/drb/drb.rb:567:in `load':
connection closed  
> (DRb:RbConnEr
ror)

I bet the connection came from ::1:9000 so DRb closed the
connection.

-- 
Eric Hodel - drbrainsegment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotco
op.com



reproducible bug in DRb on OSX
user name
2006-05-17 02:51:21
On May 16, 2006, at 5:57 PM, Eric Hodel wrote:

> On May 16, 2006, at 12:25 PM, cremes.devlistmac.com
wrote:
>> [snip]
>>                     [],
>>                     :tcp_acl => ACL.new('allow
127.0.0.1'.split("  
>> "), ACL::ALLOW_DENY) # <-- causes failure
>>                     #:tcp_acl => ACL.new('allow
localhost'.split("  
>> "), ACL::ALLOW_DENY)  <-- works
>>                     # works if you replace
127.0.0.1 with localhost
>
> DRb chose to listen on the IPv6 socket, so you'll need
to allow  
> both 127.0.0.1 and ::1 or just use localhost.
>
> You could also try removing ::1 localhost from
/etc/hosts, that  
> might fix it.

Adding "allow ::1" also makes this work. So, it
appears to be a ipv6  
issue with DRb. Any hint as to how to fix this in a
permanent  
fashion. Alternately, I can write up a short explanation
(inventing  
things along the way to fill in my knowledge gaps) and
submit it to  
the DRb maintainer as a documentation patch.

I can go either way.

>> # wait for the DRb service to finish before exiting
>> DRb.thread.join
>> -------------
>>
>> The error displayed by the client is:
>>
>> ~/developer/projects/ruby/bugs/drb-acl cremes$ ruby
-w  
>> simple_client.rb druby://localhost:9000
>> /opt/local/lib/ruby/1.8/drb/drb.rb:567:in `load':
connection  
>> closed (DRb:RbConnEr
ror)
>
> I bet the connection came from ::1:9000 so DRb closed
the connection.

This is apparently correct based on my success with adding
"allow :: 
1" to the ACL.

cr


reproducible bug in DRb on OSX
user name
2006-05-17 03:51:00
On May 16, 2006, at 7:51 PM, cremes.devlistmac.com
wrote:
> On May 16, 2006, at 5:57 PM, Eric Hodel wrote:
>> On May 16, 2006, at 12:25 PM, cremes.devlistmac.com
wrote:
>>> [snip]
>>>                     [],
>>>                     :tcp_acl =>
ACL.new('allow 127.0.0.1'.split("  
>>> "), ACL::ALLOW_DENY) # <-- causes
failure
>>>                     #:tcp_acl =>
ACL.new('allow localhost'.split 
>>> (" "), ACL::ALLOW_DENY)  <--
works
>>>                     # works if you replace
127.0.0.1 with localhost
>>
>> DRb chose to listen on the IPv6 socket, so you'll
need to allow  
>> both 127.0.0.1 and ::1 or just use localhost.
>>
>> You could also try removing ::1 localhost from
/etc/hosts, that  
>> might fix it.
>
> Adding "allow ::1" also makes this work.
So, it appears to be a  
> ipv6 issue with DRb.

127.0.0.1 is not a valid IPv6 address.  This was a bug in
your code  
not handling IPv6 addresses when your OS uses them.

> Any hint as to how to fix this in a permanent fashion.

a) Make your DNS work for IPv4 and IPv6 and bind to both
IPv6 and  
IPv4 addresses on your machine for interoperability.
b) Never use IPv6.

-- 
Eric Hodel - drbrainsegment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotco
op.com



reproducible bug in DRb on OSX
user name
2006-05-17 17:27:08
Quoting drbrainsegment7.net, on Wed, May 17, 2006 at
12:51:00PM +0900:
> On May 16, 2006, at 7:51 PM, cremes.devlistmac.com
wrote:
> 127.0.0.1 is not a valid IPv6 address.  This was a bug
in your code  
> not handling IPv6 addresses when your OS uses them.
> 
> >Any hint as to how to fix this in a permanent
fashion.
> 
> a) Make your DNS work for IPv4 and IPv6 and bind to
both IPv6 and  
> IPv4 addresses on your machine for interoperability.
> b) Never use IPv6.

It might be useful if DRb could be told what IP versions to
use with
localhost, so nice names like 'localhost' can be used with
it, and we
can leave IPv6 configured for services where you want it.

Socket.gethostbyname("localhost") returns an
IPv6 addr on OS X if IPv6
is enabled,  getaddrinfo() can be used instead to
distinguish which
protocol is wanted:

 Socket.getaddrinfo('localhost', 0, Socket::AF_INET, 
Socket::SOCK_STREAM)[0][3]
 Socket.getaddrinfo('localhost', 0, Socket::AF_INET6,
Socket::SOCK_STREAM)[0][3]

Sam


[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )