Project

General

Profile

Bug #12702 ยป drb_block_error.rb

code to reproduce the problem - djellemah (John Anderson), 08/24/2016 11:45 AM

 
require 'drb'

class Front
include DRbUndumped

def remote_method
return :no_block unless block_given?
yield :with_block
:last
end
end

URI = 'druby://localhost:6947'

def thread_server
DRb.start_service URI, Front.new
end

def process_server
server_pid = fork do
server = DRb.start_service URI, Front.new
server.thread.join
end

at_exit{ Process.kill 'TERM', server_pid }
end

# in-process works OK
thread_server

# out-of-process fails
# process_server

# give server time to start listening, just to show it's not server startup
# delay causing the error. Not necessary otherwise.
sleep 0.5

proxy = DRbObject.new_with_uri URI
values = []

# This always succeeds
values << proxy.remote_method

# calling the method with a block raises
# DRb::DRbConnError: DRb::DRbServerNotFound
# with out-of-process server.
#
# But works OK with in-process server.
values << (proxy.remote_method{|a| values << a} rescue $!.message)

# should be {:values=>[:no_block, :with_block, :last]}
p values: values

# applies to ruby-2.3.1 and ruby-2.4.0dev (2016-08-24 trunk 55999)
#
# The problem starts in DRbObject#method_missing where
# the code following DRb.here? is used for the in-process case which works.

# But the code in the block for

# succ, result = self.class.with_friend(@uri) do

# is used for the out-of-process case. Here, DrbMessage#send_request fails
# because b is a Proc, and in DrbMessage#dump the call to make_proxy fails
# because DRbObject.new(b) fails.
    (1-1/1)