[ruby-core:122742] [Ruby Bug#21512] Socket.tcp_with_fast_fallback('example.com', 80, '127.0.0.1') fails with unknown socket domain: ipv4 (SocketError)

Issue #21512 has been reported by osyoyu (Daisuke Aritomo). ---------------------------------------- Bug #21512: Socket.tcp_with_fast_fallback('example.com', 80, '127.0.0.1') fails with unknown socket domain: ipv4 (SocketError) https://bugs.ruby-lang.org/issues/21512 * Author: osyoyu (Daisuke Aritomo) * Status: Open * ruby -v: ruby 3.5.0dev (2025-07-13T04:37:15Z master f03cc0b514) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- The following code is expected to open a socket bound to the local IPv4 interface, but raises an SocketError. ```ruby require 'socket' Socket.tcp_with_fast_fallback('localhost', 8080, '127.0.0.1') ``` Expected behavior: Returns a `Socket` object Actuai behavior: Causes a SocketError (unknown socket domain: ipv4) I believe this is because Socket.tcp_with_fast_fallback is calling Addrinfo.getaddrinfo with `:ipv4` / `:ipv6` as its third argument, instead of `Socket::AF_INET` / `Socket::AF_INET6`. https://github.com/ruby/ruby/blob/b2a7b7699261d2a4ef8a9d5d38d3fb9dc99c8253/e... -- https://bugs.ruby-lang.org/

Issue #21512 has been updated by osyoyu (Daisuke Aritomo). I have opened a pull request: https://github.com/ruby/ruby/pull/13878 This bug is around from Ruby 3.4 when HEv2 was introduced. ---------------------------------------- Bug #21512: Socket.tcp_with_fast_fallback('example.com', 80, '127.0.0.1') fails with unknown socket domain: ipv4 (SocketError) https://bugs.ruby-lang.org/issues/21512#change-114023 * Author: osyoyu (Daisuke Aritomo) * Status: Open * ruby -v: ruby 3.5.0dev (2025-07-13T04:37:15Z master f03cc0b514) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- The following code is expected to open a socket bound to the local IPv4 interface, but raises an SocketError. ```ruby require 'socket' Socket.tcp_with_fast_fallback('localhost', 8080, '127.0.0.1') ``` Expected behavior: Returns a `Socket` object Actuai behavior: Causes a SocketError (unknown socket domain: ipv4) I believe this is because Socket.tcp_with_fast_fallback is calling Addrinfo.getaddrinfo with `:ipv4` / `:ipv6` as its third argument, instead of `Socket::AF_INET` / `Socket::AF_INET6`. https://github.com/ruby/ruby/blob/b2a7b7699261d2a4ef8a9d5d38d3fb9dc99c8253/e... -- https://bugs.ruby-lang.org/

Issue #21512 has been updated by hsbt (Hiroshi SHIBATA). Status changed from Open to Assigned Assignee set to shioimm (Misaki Shioi) ---------------------------------------- Bug #21512: Socket.tcp_with_fast_fallback('example.com', 80, '127.0.0.1') fails with unknown socket domain: ipv4 (SocketError) https://bugs.ruby-lang.org/issues/21512#change-114053 * Author: osyoyu (Daisuke Aritomo) * Status: Assigned * Assignee: shioimm (Misaki Shioi) * ruby -v: ruby 3.5.0dev (2025-07-13T04:37:15Z master f03cc0b514) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- The following code is expected to open a socket bound to the local IPv4 interface, but raises an SocketError. ```ruby require 'socket' Socket.tcp_with_fast_fallback('localhost', 8080, '127.0.0.1') ``` Expected behavior: Returns a `Socket` object Actuai behavior: Causes a SocketError (unknown socket domain: ipv4) I believe this is because Socket.tcp_with_fast_fallback is calling Addrinfo.getaddrinfo with `:ipv4` / `:ipv6` as its third argument, instead of `Socket::AF_INET` / `Socket::AF_INET6`. https://github.com/ruby/ruby/blob/b2a7b7699261d2a4ef8a9d5d38d3fb9dc99c8253/e... -- https://bugs.ruby-lang.org/

Issue #21512 has been updated by shioimm (Misaki Shioi). I merged this fix. Thank you! ---------------------------------------- Bug #21512: Socket.tcp_with_fast_fallback('example.com', 80, '127.0.0.1') fails with unknown socket domain: ipv4 (SocketError) https://bugs.ruby-lang.org/issues/21512#change-114057 * Author: osyoyu (Daisuke Aritomo) * Status: Closed * Assignee: shioimm (Misaki Shioi) * ruby -v: ruby 3.5.0dev (2025-07-13T04:37:15Z master f03cc0b514) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- The following code is expected to open a socket bound to the local IPv4 interface, but raises an SocketError. ```ruby require 'socket' Socket.tcp_with_fast_fallback('localhost', 8080, '127.0.0.1') ``` Expected behavior: Returns a `Socket` object Actuai behavior: Causes a SocketError (unknown socket domain: ipv4) I believe this is because Socket.tcp_with_fast_fallback is calling Addrinfo.getaddrinfo with `:ipv4` / `:ipv6` as its third argument, instead of `Socket::AF_INET` / `Socket::AF_INET6`. https://github.com/ruby/ruby/blob/b2a7b7699261d2a4ef8a9d5d38d3fb9dc99c8253/e... -- https://bugs.ruby-lang.org/
participants (3)
-
hsbt (Hiroshi SHIBATA)
-
osyoyu (Daisuke Aritomo)
-
shioimm (Misaki Shioi)