Bug #3124
closedSocketError on SnowLeopard (during make test-all)
Description
=begin
make test-all can't be run on Snow Leopard due to an error with TCPServer. The following code, when run on Snow Leopard will result in an error:
require 'socket'
TCPServer.new('localhost', 0)
It raises:
$ ruby test.rb
test.rb:2:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)
from test.rb:2:in `new'
from test.rb:2:in `<main>'
I've attached a script to reproduce.
=end
Files
Updated by naruse (Yui NARUSE) about 14 years ago
=begin
It is because of Mac OS X's getaddrinfo.
They raise error when it call getaddrinfo(3) with servname "0".
Whether it is Ruby's bug or Mac OS X's bug is still discussing.
see also: http://d.hatena.ne.jp/kimuraw/20100116/p1
=end
Updated by mame (Yusuke Endoh) almost 14 years ago
- Assignee set to naruse (Yui NARUSE)
=begin
Hi, Naruse
It is because of Mac OS X's getaddrinfo.
They raise error when it call getaddrinfo(3) with servname "0".
Whether it is Ruby's bug or Mac OS X's bug is still discussing.
So what's the conclusion?
--
Yusuke Endoh mame@tsg.ne.jp
=end
Updated by kimuraw (Wataru Kimura) almost 14 years ago
=begin
I filed this problem of apple's ruby-1.8.7 as ID:7548770 to http://bugreport.apple.com/ at 2010-01-16.
The status the report is still "OPEN".
=end
Updated by kimuraw (Wataru Kimura) almost 14 years ago
- File patch-ruby_core_29427.diff patch-ruby_core_29427.diff added
- File test_getaddrinfo.c test_getaddrinfo.c added
=begin
I think this is a bug of Snow Leopard.
I checked results of getaddrinfo(3) with some pairs of hostname and servname.
Snow Leopard (10.6.4)
host\serv | "80" "0" "" NULL
------------+---------------------------
"localhost" | OK NG(!) OK OK
"" | OK OK NG NG
NULL | OK OK NG NG
Leopard (10.5.8)
host\serv | "80" "0" "" NULL
------------+---------------------------
"localhost" | OK OK(!) OK OK
"" | OK OK NG NG
NULL | OK OK NG NG
I make a patch for 1.9.2 r28350. this pacth makes "0" to NULL when hostname is given and servname is "0".
ruby-1.9.2dev with this patch passed all tests under test/socket/ on my Mac (10.6.4).
=end
Updated by akr (Akira Tanaka) almost 14 years ago
=begin
2010/6/18 Wataru Kimura redmine@ruby-lang.org:
Issue #3124 has been updated by Wataru Kimura.
File patch-ruby_core_29427.diff added
File test_getaddrinfo.c addedI think this is a bug of Snow Leopard.
I checked results of getaddrinfo(3) with some pairs of hostname and servname.
Your patch scatter MacOS X dependent code in raddrinfo.c.
I don't like it.
Is it possible to define getaddrinfo wrapper to fix the problem?
raddrinfo.c do it for AIX.
So AIX dependent code is not scattered.
Tanaka Akira
=end
Updated by kimuraw (Wataru Kimura) almost 14 years ago
=begin
Thanks for the advice!
I rewrite the patch as patch-ruby_core_29427_2.diff.
=end
Updated by akr (Akira Tanaka) almost 14 years ago
=begin
2010/6/18 Wataru Kimura redmine@ruby-lang.org:
I rewrite the patch as patch-ruby_core_29427_2.diff.
The patch for ext/socket/raddrinfo.c is acceptable.
But the patch for test/socket/test_socket.rb is not.
- The result of Socket.gethostname may not be resolvable.
- Opned IO should be closed.
--
Tanaka Akira
=end
Updated by kimuraw (Wataru Kimura) almost 14 years ago
=begin
I modified test/socket/test_socket.rb with tanaka-san's suggestions.
(attached file patch-ruby_core_29427_3.diff)
thanks again!
=end
Updated by akr (Akira Tanaka) almost 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r28401.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end