getaddrinfo() returns wrong scope ID for IPv6 link-local addresses when type=SocketKind.SOCK_STREAM
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- networking
Research direction
Start by running the provided reproduction script on Linux with a link-local IPv6 address, comparing uvloop with vanilla asyncio and socket.getaddrinfo(). The issue is done when uvloop returns the correct nonzero scope ID for SOCK_STREAM, matching the other implementations.
Written by the indexing model from the issue text.
Description
- uvloop version: 0.17.0
- Python version: 3.11.3
- Platform: Linux
- Can you reproduce the bug with
PYTHONASYNCIODEBUGin env?: yes - Does uvloop behave differently from vanilla asyncio? How?: Vanilla asyncio returns the correct scope ID, uvloop returns 0
When passing type=SocketKind.SOCK_STREAM to getaddrinfo() in uvloop, the scope ID for link-local addresses is left as 0. This works correctly (returns nonzero scope ID) in socket.getaddrinfo() and vanilla asyncio's corresponding function.
Repro script (requires psutil installed):
from asyncio import get_running_loop, run
from socket import SocketKind
import psutil
import uvloop
async def main():
for ifname, addresses in psutil.net_if_addrs().items():
for addr in addresses:
if addr.address.startswith("fe80::") and "%" in addr.address:
gai_res = await get_running_loop().getaddrinfo(addr.address, 0, type=SocketKind.SOCK_STREAM)
scope_id = gai_res[-1][-1][-1]
print("Scope id for", gai_res[-1], "is", scope_id)
return
print("Could not find a suitable link-local address")
# Comment out this line, and it works fine
uvloop.install()
run(main())
- Dominant language
- Cython
- Stars
- 11.9k
- Forks
- 615
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MagicStack/uvloop
-
License not clear Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MagicStack/uvloop#759 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MagicStack/uvloop#741 · 2 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MagicStack/uvloop#702 · 8 comments · 9 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
MagicStack/uvloop#766 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
MagicStack/uvloop#765 ·
All issues in MagicStack/uvloop
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-mgmt#28113 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
canonical/postgresql-watcher-operator#110 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
EleutherAI/lm-evaluation-harness#4201 ·