uvloop icon indicating copy to clipboard operation
uvloop copied to clipboard

uvloop is broken for abstract sockets - create_unix_connection does not work for abstract sockets as libuv does not support them

Open GrahamBarnett opened this issue 2 years ago • 4 comments

  • uvloop version: master
  • Python version: 3.10+
  • Platform: unix
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes
  • Does uvloop behave differently from vanilla asyncio? How?: yes

uvloop: tr = UnixTransport.new(self, protocol, None, waiter, context) tr.connect(path) <--- uses uv_pipe_connect which uses uv__strscpy which assumes zero terminated string

asyncio: sock_connect -> getsockaddrarg (in socketmodule.c) which uses memcpy

I have raised this with libuv as issue: https://github.com/libuv/libuv/discussions/3911

GrahamBarnett avatar Feb 20 '23 15:02 GrahamBarnett

Note: This means that abstract socket clients do not work at all in uvloop

GrahamBarnett avatar Feb 20 '23 15:02 GrahamBarnett

From libuv:

Libuv doesn't support abstract Linux sockets out of the box (because not cross-platform) but you can create and bind the socket manually, then pass it to uv_pipe_open().

You can use the pipe_getsockname_abstract test in test/test-pipe-getsockname.c as a how-to.

GrahamBarnett avatar Feb 20 '23 20:02 GrahamBarnett

uvlib have now exposed uv_pipe_connect2 that takes the address length (and therefore does not internally use strlen on the address). Do you have any objection to switching to using that, then the code will be generic? https://github.com/libuv/libuv/commit/d843b7cf7fe77ff2c134e7de9f1ce79fbecda7a6 Thanks.

GrahamBarnett avatar Jun 03 '24 15:06 GrahamBarnett