Skip to content

src/unix/core.c:896: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed. when opening a datagram endpoint #125

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

Closed
matthiasblondeel opened this issue Feb 12, 2018 · 3 comments
Labels

Comments

@matthiasblondeel
Copy link

matthiasblondeel commented Feb 12, 2018

  • uvloop version: 0.9
  • Python version: 3.6.1
  • Platform: Linux
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: YES

In uvloop 0.9 it looks like an issue was introduced when creating new udp endpoints.
The below code works fine with uvloop 0.8, but fails and crashes the process in uvloop 0.9

import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

receive_addr = ('127.0.0.1', 1234)

async def crash_python():
    counter = 0
    while True:
        transport, _ = await asyncio.get_event_loop().create_datagram_endpoint(
             asyncio.Protocol, reuse_port=True, local_addr=receive_addr)
        print('started', counter)
        counter+=1
        await asyncio.sleep(0.1)
    
asyncio.get_event_loop().run_until_complete(crash_python())

On my system it takes somewhere between 10 and 90 iterations of the counter before a crash occurs.
I get the following assertion:

python: src/unix/core.c:896: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
@1st1
Copy link
Member

1st1 commented May 23, 2018

An obvious fix is to manually call transport.close() instead of relying on GC. But uvloop shouldn't crash regardless. Looking into this.

@1st1
Copy link
Member

1st1 commented May 23, 2018

Looks like the new UDP implementation is a bit racy w.r.t. GC. Ideally we should just revert to use uv_udp_t implementation, but that's blocked on #120 and libuv/leps#10.

@1st1 1st1 added the libuv label May 23, 2018
1st1 added a commit that referenced this issue Aug 2, 2018
This makes the GC of UDPTransport<->UVPoll pair more deterministic
and avoids a segfault.

Fixes #125.
@1st1 1st1 closed this as completed in #190 Aug 2, 2018
1st1 added a commit that referenced this issue Aug 2, 2018
This makes the GC of UDPTransport<->UVPoll pair more deterministic
and avoids a segfault.

Fixes #125.
1st1 added a commit that referenced this issue Aug 2, 2018
This makes the GC of UDPTransport<->UVPoll pair more deterministic
and avoids a segfault.

Fixes #125.
@aptonline
Copy link

Any chance the above reference (#20829) can be investigated? After removing uvloop 0.12.0 from Home Assistant my docker container has not crashed once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants