UDPSocket bug?

Hello all,

This code fails on WindowsInstallerRuby
ruby 1.7.2 (2002-07-02) [i386-mswin32]
with
[BUG] rb_sys_fail() - errno == 0
but runs on
ruby 1.6.6 (2001-12-26) [i486-linux]
without a problem.

Bug? Well, it says so :slight_smile:

Danny

···

require 'socket’
server=UDPSocket.open
server.bind(nil, 50403)
client=UDPSocket.open
client.connect(‘127.0.0.1’, 50403)
puts 'works:'
client.send(‘12345’,0)
server.recvfrom(5)
puts 'fails:'
client.send(‘123456789’,0)
server.recvfrom(5)

ah ha! that’s may be the root of tcp’s and http’s bugs as well!
i had to switch back to 1.6.7 becasue of them. (linux though)

···

On Tue, 2002-09-10 at 13:04, Danny van Bruggen wrote:

Hello all,

This code fails on WindowsInstallerRuby
ruby 1.7.2 (2002-07-02) [i386-mswin32]
with
[BUG] rb_sys_fail() - errno == 0
but runs on
ruby 1.6.6 (2001-12-26) [i486-linux]
without a problem.

Bug? Well, it says so :slight_smile:

Danny


require 'socket’
server=UDPSocket.open
server.bind(nil, 50403)
client=UDPSocket.open
client.connect(‘127.0.0.1’, 50403)
puts 'works:'
client.send(‘12345’,0)
server.recvfrom(5)
puts 'fails:'
client.send(‘123456789’,0)
server.recvfrom(5)


tom sawyer, aka transami
transami@transami.net

Hmm, I wonder if Winsock isn’t setting errno properly. If that’s the
case, then rb_sys_fail() won’t be sufficient for socket.c.

Paul

···

On Wed, Sep 11, 2002 at 04:04:50AM +0900, Danny van Bruggen wrote:

[BUG] rb_sys_fail() - errno == 0

Here’s another one:

works:
fails:
-:11:in `recvfrom’: Unknown Error - “recvfrom(2)” (Errno::E10040)
from -:11

C:\ruby\bin>ruby -v
ruby 1.6.6 (2001-12-26) [i586-mswin32]

···

On Wed, 11 Sep 2002, Paul Brannan wrote:

On Wed, Sep 11, 2002 at 04:04:50AM +0900, Danny van Bruggen wrote:

[BUG] rb_sys_fail() - errno == 0

Hmm, I wonder if Winsock isn’t setting errno properly. If that’s the
case, then rb_sys_fail() won’t be sufficient for socket.c.

Paul

According to http://www.sockets.com/a_c2.htm (and a few other sources),
meaningful winsock error information cannot be obtained from errno;
WSAGetLastError() should be used instead. In this situation,
rb_sys_fail won’t work.

If I actually had a compiler installed on Windows, I’d write a patch,
but this should be an easy fix anyway.

This explains why the code was failing with such a strange error
message; I wonder why it was failing in the first place, though.

Paul

···

On Wed, Sep 11, 2002 at 05:37:40AM +0900, Paul Brannan wrote:

On Wed, Sep 11, 2002 at 04:04:50AM +0900, Danny van Bruggen wrote:

[BUG] rb_sys_fail() - errno == 0

Hmm, I wonder if Winsock isn’t setting errno properly. If that’s the
case, then rb_sys_fail() won’t be sufficient for socket.c.

The other message I sent had a reasonable winsock error for some
reason: 10040.

winsock2.h tells me

#define WSABASEERR 10000
#define WSAEMSGSIZE (WSABASEERR+40)

then we get
http://mail.python.org/pipermail/patches/2001-February/004072.html
which states that I did a recv but the datagram was too big for my
buffer. That’s right. Linux didn’t feel that was an error though. And,
something has changed between Ruby 1.6.6 and 1.7.2 that shouldn’t have
been changed…

  1. Behaviour of Linux and Windows has been different in all version I have
  2. 1.7 looks at the wrong errorcode.

There must be someone with a compiler and sourcetree set up for fixing :slight_smile:

Danny

···

On Wed, Sep 11, 2002 at 05:37:40AM +0900, Paul Brannan wrote:

On Wed, Sep 11, 2002 at 04:04:50AM +0900, Danny van Bruggen wrote:

[BUG] rb_sys_fail() - errno == 0

Hmm, I wonder if Winsock isn’t setting errno properly. If that’s the
case, then rb_sys_fail() won’t be sufficient for socket.c.

According to http://www.sockets.com/a_c2.htm (and a few other sources),
meaningful winsock error information cannot be obtained from errno;
WSAGetLastError() should be used instead. In this situation,
rb_sys_fail won’t work.

If I actually had a compiler installed on Windows, I’d write a patch,
but this should be an easy fix anyway.

This explains why the code was failing with such a strange error
message; I wonder why it was failing in the first place, though.

Paul

Hi,

···

At Thu, 12 Sep 2002 04:33:54 +0900, Paul Brannan wrote:

[BUG] rb_sys_fail() - errno == 0

Hmm, I wonder if Winsock isn’t setting errno properly. If that’s the
case, then rb_sys_fail() won’t be sufficient for socket.c.

According to http://www.sockets.com/a_c2.htm (and a few other sources),
meaningful winsock error information cannot be obtained from errno;
WSAGetLastError() should be used instead. In this situation,
rb_sys_fail won’t work.

errno should be set in win32/win32.c:rb_w32_recvfrom().


Nobu Nakada

If it should be set, then why was an “errno == 0” error generated?

Paul

···

On Thu, Sep 12, 2002 at 04:06:32PM +0900, Nobuyoshi Nakada wrote:

errno should be set in win32/win32.c:rb_w32_recvfrom().

Hi,

···

At Thu, 12 Sep 2002 22:51:15 +0900, Paul Brannan wrote:

errno should be set in win32/win32.c:rb_w32_recvfrom().

If it should be set, then why was an “errno == 0” error generated?

It’s the question.

I found myself misread a little, error in [ruby-talk:49898]
apparently differs from one in first article. If so, in which
line it occurred?


Nobu Nakada

Both the error in [ruby-talk:49768] and the error in [ruby-talk:49898]
mentioned “recvfrom(2).” There is only one line in socket.c which calls
rb_sys_fail with a parameter of “recvfrom(2)”.

Or do you mean which line in the Ruby code? The first article didn’t
mention a line number, but the latter one did. I suspect they both
occurred on line 11, though.

Paul

···

On Thu, Sep 12, 2002 at 11:20:23PM +0900, nobu.nokada@softhome.net wrote:

At Thu, 12 Sep 2002 22:51:15 +0900, Paul Brannan wrote:

If it should be set, then why was an “errno == 0” error generated?

It’s the question.

I found myself misread a little, error in [ruby-talk:49898]
apparently differs from one in first article. If so, in which
line it occurred?