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

Inadequate exception thrown when creating IPv6 socket on win32/msvc #5398

Closed
vicuna opened this Issue Nov 14, 2011 · 11 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link
Collaborator

commented Nov 14, 2011

Original bug ID: 5398
Reporter: ripoche
Assigned to: @protz
Status: closed (set by @xavierleroy on 2015-12-11T18:07:10Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.12.1
Target version: 4.01.0+dev
Fixed in version: 4.00.0+dev
Category: platform support (windows, cross-compilation, etc)
Child of: #5676
Monitored by: @protz

Bug description

Unix.socket Unix.PF_INET6 Unix.SOCK_STREAM 0

fails with the following exception on win32/msvc :
Exception: Unix.Unix_error (EUNKNOWNERR 0, "socket", "")

otherlibs/win32unix/socket.c fails does not deal with PF_INET6 and happily accesses data outside the socket_type_table array.

File attachments

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 14, 2011

Comment author: ripoche

With this patch applied, the same snippet raises the following exception :
Exception: Unix.Unix_error (Unix.EPFNOSUPPORT, "socket", "")

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Dec 21, 2011

Comment author: @protz

So this means that OCaml is unable to open PF_INET6 sockets? How complicated would it be to make sure ipv6 sockets are supported on win32? You mention requiring Winsocks2, is that a difficult requirement to match?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Dec 21, 2011

Comment author: ripoche

There are 2 issues with the current implementation:

  • trying to create an IPv6 socket makes an out-of-bound access in
    socket_domain_table.
  • PF_INET6 is only defined in WinSock2.h which is incompatible with WinSock.h.

I did a quick port to WinSock2 while investigating bug #5416 to rule out issues that could stem from mixing WinSock 1 and 2. It did compile and run fine and as a nice bonus simplified a few files (socket.c and accept.c).

Note that I didn't run any extensive checks and never tried to create an IPv6 socket with the patch applied (it's not installed on my XP box anyway). I also reverted the patch to complete the investigation on bug #5416.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 19, 2012

Comment author: @xavierleroy

I agree the patch should be applied ASAP, to avoid the out-of-bound access.

As concerns switching to WinSock2: it's something to be considered. What is the oldest version of Windows that supports WinSock2?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 23, 2012

Comment author: ripoche

From what I gathered, the early bundled versions of Winsock2 were available starting with Win98.

According to the MSDN, the full feature set is available starting with Win2K (http://msdn.microsoft.com/en-us/library/windows/desktop/ms742213%28v=vs.85%29.aspx).

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 30, 2012

Comment author: @protz

Applied both on trunk and on branch as r12104 and r12105

I would be happy to review and try a patch that transitions all the code to winsocks2.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 30, 2012

Comment author: ripoche

Would a patch based on the official 3.12.1 release be ok ?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 30, 2012

Comment author: @protz

I don't think we want such a major change to land on a release branch. 3.12.x releases are supposed to be bugfix-only releases; there is a big potential for regressions, so I do believe it's best to apply this to trunk and let it bake for a little while :)

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 10, 2012

Comment author: @damiendoligez

As far as I can tell, the bug reported above is now fixed, and we are considering switching to winsock2 and supporting IPv6. If that is correct, someone please set the target version to 4.01 (protz?).

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 10, 2012

Comment author: @protz

Ok, so I just discussed this with Damien, and supporting AF_INET6 is indeed something we want to do. However, we chose not to do it for the upcoming 4.00.0 release, since the potential for breakage seems rather high.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 10, 2012

Comment author: @protz

I'm marking this as resolved, since the parent report already has a patch. We'll do the upgrade to Winsock 2 in #5676, and this will bug will remain about the invalid AF_INET6 parameter on Windows.

@vicuna vicuna closed this Dec 11, 2015

@vicuna vicuna added this to the 4.01.0 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

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.