Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JRuby raises SystemCallError instead of Errno::EMSGSIZE #4606

Closed
dwbutler opened this Issue May 14, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@dwbutler
Copy link

dwbutler commented May 14, 2017

Environment

jruby -v
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.74-b02 on 1.8.0_74-b02 +jit [darwin-x86_64]

uname -a
Darwin Davids-MacBook-Pro-6.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

Summary

JRuby raises SystemCallError instead of Errno:: EMSGSIZE when writing too large of a message to a UDP socket. See dwbutler/logstash-logger#128.

Setup

$ nc -l 5228

Ruby script (run from irb):

require 'socket'
socket = UDPSocket.new
socket.connect('127.0.0.1', 5228)
socket.write "1"*100_000

Expected Behavior

MRI 2.4.1:

Errno::EMSGSIZE: Message too long
	from (irb):4:in `write'

Actual Behavior

JRuby 9.0.5.0:

SystemCallError: Unknown error - No message available
	from org/jruby/RubyIO.java:1437:in `write'
	from org/jruby/RubyIO.java:1408:in `write'
@etehtsea

This comment has been minimized.

Copy link
Contributor

etehtsea commented May 16, 2017

I think I can fix this.

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 17, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue May 18, 2017

@kares kares closed this in b04be74 May 24, 2017

@kares kares added this to the JRuby 9.2.0.0 milestone May 24, 2017

@kares

This comment has been minimized.

Copy link
Member

kares commented May 24, 2017

and all is well ... thanks to @etehtsea

eregon added a commit to ruby/spec that referenced this issue May 27, 2017

etehtsea added a commit to etehtsea/jruby that referenced this issue Jun 1, 2017

kares added a commit that referenced this issue Jun 1, 2017

@omarmarquez

This comment has been minimized.

Copy link

omarmarquez commented Apr 18, 2018

Is this the same bug?
`$ ruby -v
jruby 9.1.16.0 (2.3.3) 2018-02-21 8f3f95a Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 +jit [linux-x86_64]

$ ruby rcv.rb
SocketError: No message available
block in rcv.rb at rcv.rb:16
loop at org/jruby/RubyKernel.java:1316

at rcv.rb:15

$ cat rcv.rb
#!/usr/bin/env ruby
require 'socket'
require 'ipaddr'
BIND_ADDR = "0.0.0.0"
MULTICAST_ADDR = "239.203.120.1"
PORT = 10000

sock = UDPSocket.new
ip = IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new(BIND_ADDR).hton
sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1)
sock.bind(BIND_ADDR, PORT)
loop do
msg, info = sock.recvfrom(1024)
puts "MSG: #{msg} from #{info[2]} (#{info[3]})/#{info[1]} len #{msg.size}"
end`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.