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

OSError: AF_UNIX path too long under MacOS #3572

Closed
asvetlov opened this issue Jan 22, 2019 · 9 comments · Fixed by #3832
Closed

OSError: AF_UNIX path too long under MacOS #3572

asvetlov opened this issue Jan 22, 2019 · 9 comments · Fixed by #3832

Comments

@asvetlov
Copy link
Member

Surprisingly Travis fails on MacOS: https://travis-ci.com/aio-libs/aiohttp/builds/98188999?utm_medium=notification&utm_source=email

Looks like it is the result of my #3548 PR.
I have no Mac available, the investigation can be slow.
If somebody can run tests locally on Mac and debug what is wrong -- it would be awesome and save my personal time a lot.

@aio-libs-bot

This comment has been minimized.

@webknjaz webknjaz self-assigned this Jan 28, 2019
@webknjaz
Copy link
Member

I think we've already seen the issue with fs paths for unix sockets being too long in the past...

�[1m�[31m_________________________ test_unix_connector[pyloop] __________________________�[0m



unix_server = <function unix_server.<locals>.go at 0x10bfd58c8>

unix_sockname = '/private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pytest-of-travis/pytest-0/test_unix_connector_pyloop_0/socket.sock'



�[1m    @pytest.mark.skipif(not hasattr(socket, 'AF_UNIX'),�[0m

�[1m                        reason='requires UNIX sockets')�[0m

�[1m    async def test_unix_connector(unix_server, unix_sockname) -> None:�[0m

�[1m        async def handler(request):�[0m

�[1m            return web.Response()�[0m

�[1m    �[0m

�[1m        app = web.Application()�[0m

�[1m        app.router.add_get('/', handler)�[0m

�[1m>       await unix_server(app)�[0m



�[1m�[31mtests/test_connector.py�[0m:2106: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

�[1m�[31mtests/test_connector.py�[0m:60: in go

�[1m    await site.start()�[0m

�[1m�[31maiohttp/web_runner.py�[0m:128: in start

�[1m    ssl=self._ssl_context, backlog=self._backlog)�[0m

�[1m�[31m../../../.pyenv/versions/3.5.3/lib/python3.5/asyncio/coroutines.py�[0m:210: in coro

�[1m    res = func(*args, **kw)�[0m

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 



self = <_UnixSelectorEventLoop running=False closed=False debug=False>

protocol_factory = <aiohttp.web_server.Server object at 0x10c0b8048>

path = '/private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pytest-of-travis/pytest-0/test_unix_connector_pyloop_0/socket.sock'



�[1m    @coroutine�[0m

�[1m    def create_unix_server(self, protocol_factory, path=None, *,�[0m

�[1m                           sock=None, backlog=100, ssl=None):�[0m

�[1m        if isinstance(ssl, bool):�[0m

�[1m            raise TypeError('ssl argument must be an SSLContext or None')�[0m

�[1m    �[0m

�[1m        if path is not None:�[0m

�[1m            if sock is not None:�[0m

�[1m                raise ValueError(�[0m

�[1m                    'path and sock can not be specified at the same time')�[0m

�[1m    �[0m

�[1m            path = _fspath(path)�[0m

�[1m            sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)�[0m

�[1m    �[0m

�[1m            # Check for abstract socket. `str` and `bytes` paths are supported.�[0m

�[1m            if path[0] not in (0, '\x00'):�[0m

�[1m                try:�[0m

�[1m                    if stat.S_ISSOCK(os.stat(path).st_mode):�[0m

�[1m                        os.remove(path)�[0m

�[1m                except FileNotFoundError:�[0m

�[1m                    pass�[0m

�[1m                except OSError as err:�[0m

�[1m                    # Directory may have permissions only to create socket.�[0m

�[1m                    logger.error('Unable to check or remove stale UNIX socket %r: %r', path, err)�[0m

�[1m    �[0m

�[1m            try:�[0m

�[1m>               sock.bind(path)�[0m

�[1m�[31mE               OSError: AF_UNIX path too long�[0m



�[1m�[31m../../../.pyenv/versions/3.5.3/lib/python3.5/asyncio/unix_events.py�[0m:281: OSError

�[1m�[31m____________________________ test_addresses[pyloop] ____________________________�[0m



make_runner = <function make_runner.<locals>.go at 0x10c39f6a8>

tmpdir = local('/private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pytest-of-travis/pytest-0/test_addresses_pyloop_0')



�[1m    @pytest.mark.skipif(platform.system() == "Windows",�[0m

�[1m                        reason="Unix socket support is required")�[0m

�[1m    async def test_addresses(make_runner, tmpdir) -> None:�[0m

�[1m        _sock = get_unused_port_socket('127.0.0.1')�[0m

�[1m        runner = make_runner()�[0m

�[1m        await runner.setup()�[0m

�[1m        tcp = web.SockSite(runner, _sock)�[0m

�[1m        await tcp.start()�[0m

�[1m        path = str(tmpdir / 'tmp.sock')�[0m

�[1m        unix = web.UnixSite(runner, path)�[0m

�[1m>       await unix.start()�[0m



�[1m�[31mtests/test_web_runner.py�[0m:113: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

�[1m�[31maiohttp/web_runner.py�[0m:128: in start

�[1m    ssl=self._ssl_context, backlog=self._backlog)�[0m

�[1m�[31m../../../.pyenv/versions/3.5.3/lib/python3.5/asyncio/coroutines.py�[0m:210: in coro

�[1m    res = func(*args, **kw)�[0m

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 



self = <_UnixSelectorEventLoop running=False closed=False debug=False>

protocol_factory = <aiohttp.web_server.Server object at 0x10c2d0240>

path = '/private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pytest-of-travis/pytest-0/test_addresses_pyloop_0/tmp.sock'



�[1m    @coroutine�[0m

�[1m    def create_unix_server(self, protocol_factory, path=None, *,�[0m

�[1m                           sock=None, backlog=100, ssl=None):�[0m

�[1m        if isinstance(ssl, bool):�[0m

�[1m            raise TypeError('ssl argument must be an SSLContext or None')�[0m

�[1m    �[0m

�[1m        if path is not None:�[0m

�[1m            if sock is not None:�[0m

�[1m                raise ValueError(�[0m

�[1m                    'path and sock can not be specified at the same time')�[0m

�[1m    �[0m

�[1m            path = _fspath(path)�[0m

�[1m            sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)�[0m

�[1m    �[0m

�[1m            # Check for abstract socket. `str` and `bytes` paths are supported.�[0m

�[1m            if path[0] not in (0, '\x00'):�[0m

�[1m                try:�[0m

�[1m                    if stat.S_ISSOCK(os.stat(path).st_mode):�[0m

�[1m                        os.remove(path)�[0m

�[1m                except FileNotFoundError:�[0m

�[1m                    pass�[0m

�[1m                except OSError as err:�[0m

�[1m                    # Directory may have permissions only to create socket.�[0m

�[1m                    logger.error('Unable to check or remove stale UNIX socket %r: %r', path, err)�[0m

�[1m    �[0m

�[1m            try:�[0m

�[1m>               sock.bind(path)�[0m

�[1m�[31mE               OSError: AF_UNIX path too long�[0m



�[1m�[31m../../../.pyenv/versions/3.5.3/lib/python3.5/asyncio/unix_events.py�[0m:281: OSError

@webknjaz
Copy link
Member

webknjaz commented Jun 9, 2019

To fix this we'll need to use tmpdir_factory fixture: https://github.com/agronholm/anyio/pull/42/files#diff-f0c1c7497545019b8489fa8bc06be6cdR208

@webknjaz webknjaz changed the title Failed MacOS build OSError: AF_UNIX path too long under MacOS Jun 9, 2019
@webknjaz
Copy link
Member

webknjaz commented Jun 9, 2019

Ref: ethereum/trinity#404 (comment)

@asvetlov
Copy link
Member Author

asvetlov commented Jun 9, 2019

@webknjaz if you want to provide some information adding a link without any comment is not very helpful

@asvetlov
Copy link
Member Author

asvetlov commented Jun 9, 2019

Sorry, missed your prev comment.

@asvetlov
Copy link
Member Author

asvetlov commented Jun 9, 2019

As a part of #3827 I've just skipped these two failed tests on MacOSX.
Don't want to spend time by fighting with MacOS weirdness.

@webknjaz
Copy link
Member

webknjaz commented Jun 9, 2019

@asvetlov it's not just macOS, all NIXes have different limits. You can hit it under Linux too. I almost have a PR for this. So stay tuned :)

@asvetlov
Copy link
Member Author

asvetlov commented Jun 9, 2019

I don't care too much.
If you have a PR -- let's review/apply it.
Otherwise just skipping is good enough for 2 very minor tests

@helpr helpr bot added the pr-available label Jun 9, 2019
@helpr helpr bot added pr-merged and removed pr-available labels Jun 11, 2019
webknjaz added a commit that referenced this issue Jun 11, 2019
Fixes #3572

Different OS kernels have different fs path length limitations
for it. For Linux, it's 108, for HP-UX it's 92 (or higher) depending
on its version. For most of the BSDs (Open, Free, macOS) it's
mostly 104 but sometimes it can be down to 100.

Ref: https://unix.stackexchange.com/a/367012/27133

This change implements a flexible socket path generator fixture
which guarantees that it's fit into the memory space allocated
by the kernel of the current OS runtime.
simonchatts added a commit to simonchatts/nixpkgs that referenced this issue Jun 19, 2020
Disable a non-critical test known to fail on Darwin (see aio-libs/aiohttp#3572)
@lock lock bot added the outdated label Jun 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
webknjaz added a commit to webknjaz/aiohttp that referenced this issue Sep 7, 2022
Fixes aio-libs#3572

Different OS kernels have different fs path length limitations
for it. For Linux, it's 108, for HP-UX it's 92 (or higher) depending
on its version. For most of the BSDs (Open, Free, macOS) it's
mostly 104 but sometimes it can be down to 100.

Ref: https://unix.stackexchange.com/a/367012/27133

This change implements a flexible socket path generator fixture
which guarantees that it's fit into the memory space allocated
by the kernel of the current OS runtime.

(cherry picked from commit 8e9e39b)
webknjaz added a commit that referenced this issue Sep 7, 2022
Fixes #3572

Different OS kernels have different fs path length limitations
for it. For Linux, it's 108, for HP-UX it's 92 (or higher) depending
on its version. For most of the BSDs (Open, Free, macOS) it's
mostly 104 but sometimes it can be down to 100.

Ref: https://unix.stackexchange.com/a/367012/27133

This change implements a flexible socket path generator fixture
which guarantees that it's fit into the memory space allocated
by the kernel of the current OS runtime.

(cherry picked from commit 8e9e39b)
webknjaz added a commit that referenced this issue Sep 7, 2022
Fixes #3572

Different OS kernels have different fs path length limitations
for it. For Linux, it's 108, for HP-UX it's 92 (or higher) depending
on its version. For most of the BSDs (Open, Free, macOS) it's
mostly 104 but sometimes it can be down to 100.

Ref: https://unix.stackexchange.com/a/367012/27133

This change implements a flexible socket path generator fixture
which guarantees that it's fit into the memory space allocated
by the kernel of the current OS runtime.

(cherry picked from commit 8e9e39b)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants