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

Unable to run compiler or stdlib specs with IPv6 disabled #15033

Closed
Blacksmoke16 opened this issue Sep 25, 2024 · 5 comments · Fixed by #15046
Closed

Unable to run compiler or stdlib specs with IPv6 disabled #15033

Blacksmoke16 opened this issue Sep 25, 2024 · 5 comments · Fixed by #15046
Assignees
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:specs platform:unix

Comments

@Blacksmoke16
Copy link
Member

Blacksmoke16 commented Sep 25, 2024

At some point in the past while debugging something else, I ended up adding the ipv6.disable=1 kernel parameter. This seems to break the compiler and stdlib specs due to:

Unhandled exception: Failed to create socket: Address family not supported by protocol (Socket::Error)
  from src/crystal/system/unix/socket.cr:12:5 in 'create_handle'
  from src/socket.cr:68:10 in 'initialize'
  from src/socket/tcp_socket.cr:40:5 in 'initialize'
  from src/socket/tcp_server.cr:38:7 in 'initialize:reuse_port'
  from src/socket/tcp_server.cr:36:3 in 'new:reuse_port'
  from src/socket/tcp_server.cr:70:14 in 'supports_ipv6?'
  from spec/std/socket/spec_helper.cr:26:6 in 'each_ip_family'
  from spec/std/http/web_socket_spec.cr:360:3 in '->'
  from src/spec/context.cr:286:15 in 'describe'
  from src/spec/methods.cr:20:5 in 'describe'
  from spec/std/http/web_socket_spec.cr:47:1 in '__crystal_main'
  from src/crystal/main.cr:118:5 in 'main_user_code'
  from src/crystal/main.cr:104:7 in 'main'
  from src/crystal/main.cr:130:3 in 'main'
  from /usr/lib/libc.so.6 in '??'
  from /usr/lib/libc.so.6 in '__libc_start_main'
  from .build/std_spec in '_start'
  from ???
make: *** [Makefile:106: std_spec] Error 1

We are checking if IPv6 is enabled via SocketSpecHelper.supports_ipv6?, but we're only catching Socket::BindError whereas the error raised here is a Socket::Error. Will also need to address unused_local_port always using IPv6 as well.

@Blacksmoke16 Blacksmoke16 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:specs labels Sep 25, 2024
@Blacksmoke16 Blacksmoke16 self-assigned this Sep 25, 2024
@Blacksmoke16
Copy link
Member Author

Some networking specs do

TCPServer.open(0) do |tcp_server|
which ends up using "::" as the host. These specs ultimately fail when IPv6 is disabled. Is there any meaningful difference between "::" and "0.0.0.0" in this context? Was thinking we could update these usages to use the IPv4 variant to avoid needing extra IPv6 checks.

@ysbaddaden
Copy link
Contributor

Yes :: binds to ipv6 and ipv4, while 0.0.0.0 only binds to ipv4.

@ysbaddaden
Copy link
Contributor

We want the former behavior by default, not the latter.

I'm wondering in which context is ipv6 disabled? I mean, we're in 2024.

@Blacksmoke16
Copy link
Member Author

We want the former behavior by default, not the latter.

Yea that makes sense in the real code, but to be clear I was more so proposing just changing it in these specs. E.g.

it "don't sync_close" do
  TCPServer.open(0) do |tcp_server|
    context = OpenSSL::SSL::Context::Server.new
    ssl_server = OpenSSL::SSL::Server.new(tcp_server, context, sync_close: false)
    ssl_server.context.should eq context

    ssl_server.close

    tcp_server.closed?.should be_false
  end
end

Does it really matter if we bind an IPv6 vs IPv4 in this context?

@straight-shoota
Copy link
Member

It appears the behaviour of :: can vary, as previously mentioned in #6711 (comment).
I suppose this might be the case in @Blacksmoke16's environment that :: does not include ipv4 as well and thus the bind fails with ipv6 disabled?

Anyway, I'm wondering if using an unspecified address is even good in the first place.
Shouldn't these servers bind to loopback instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:specs platform:unix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants