classification
Title: DatagramProtocol + IPv6 does not work with ProactorEventLoop
Type: behavior Stage: patch review
Components: asyncio, Windows Versions: Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alex.gronholm, asvetlov, kbr, njs, paul.moore, steve.dower, tim.golden, yselivanov, zach.ware
Priority: normal Keywords: patch

Created on 2019-12-28 10:55 by alex.gronholm, last changed 2020-04-05 07:19 by kbr.

Files
File name Uploaded Description Edit
udpreceive.py alex.gronholm, 2019-12-28 10:55 Script to reproduce the error
Pull Requests
URL Status Linked Edit
PR 19121 open kbr, 2020-03-23 18:26
Messages (8)
msg358940 - (view) Author: Alex Grönholm (alex.gronholm) * Date: 2019-12-28 10:55
Receiving a UDP datagram using DatagramProtocol on the Proactor event loop results in error_received() being called with WinError 87 (Invalid Parameter). The low-level sock_recv() works fine, but naturally loses the sender address information. The attached script works fine as-is on Linux, and on Windows if ::1 is replaced with 127.0.0.1.

There were extensive tests added for UDP support on IOCP, but unfortunately all of them use only IPv4 sockets so they could not catch this problem.
msg364803 - (view) Author: Kjell Braden (kbr) * Date: 2020-03-22 12:52
I tried some debugging with Python 3.9.0a4 and it looks like unparse_address in overlapped.c (https://github.com/python/cpython/blob/v3.9.0a4/Modules/overlapped.c#L689) raises the error. Almost seems like ENABLE_IPV6 is not set...
msg364807 - (view) Author: Kjell Braden (kbr) * Date: 2020-03-22 16:01
Just to confirm, for some reason ENABLE_IPV6 is not set when compiling _overlapped. I'm not familiar enough with the windows build infrastructure to submit a PR though.
msg364837 - (view) Author: Alex Grönholm (alex.gronholm) * Date: 2020-03-23 06:02
Well, I found this: https://github.com/python/cpython/blob/3c97e1e457033bbb8bbe0b7198bd13fc794a12b0/configure.ac#L3278-L3279
Could it be that the official binaries were compiled without --enable-ipv6?
msg364841 - (view) Author: Kjell Braden (kbr) * Date: 2020-03-23 09:23
./configure is not run on Windows, but I believe the define should go here:

https://github.com/python/cpython/blob/8510f430781118d9b603c3a2f06945d6ebc5fe42/PC/pyconfig.h#L678
msg364842 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-03-23 09:57
Would somebody be a champion for the issue?
msg364861 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-03-23 16:21
Main thing we need is a PR (straightforward) and confirming that the relevant tests all run. We can use the buildbot fleet to make sure that all supported platforms have the necessary APIs, but it wouldn't surprise me if there's some weird edge cases here.
msg365813 - (view) Author: Kjell Braden (kbr) * Date: 2020-04-05 07:19
PR is up. Any chance we get this reviewed for inclusion in 3.9.0a6 / 3.8.3rc1?
History
Date User Action Args
2020-04-05 07:19:28kbrsetmessages: + msg365813
2020-03-23 18:26:20kbrsetkeywords: + patch
stage: patch review
pull_requests: + pull_request18482
2020-03-23 16:21:48steve.dowersetmessages: + msg364861
2020-03-23 09:57:37asvetlovsetmessages: + msg364842
2020-03-23 09:23:54kbrsetmessages: + msg364841
2020-03-23 06:02:28alex.gronholmsetmessages: + msg364837
2020-03-22 16:01:11kbrsetmessages: + msg364807
versions: + Python 3.9
2020-03-22 12:52:40kbrsetmessages: + msg364803
2020-03-22 10:21:39kbrsetfiles: - udp_ipv6_server.py
2020-03-22 10:21:29kbrsetfiles: + udp_ipv6_server.py
nosy: + kbr
2019-12-28 22:23:10njssetnosy: + njs
2019-12-28 10:57:07alex.gronholmsetnosy: + yselivanov
components: + asyncio
2019-12-28 10:55:11alex.gronholmcreate