Skip to content

Guard Server.close/_unref when constructed with loop=None - #780

Closed
Eryx-Z wants to merge 1 commit into
MagicStack:masterfrom
Eryx-Z:fix/server-none-close-segfault
Closed

Eryx-Z wants to merge 1 commit into
MagicStack:masterfrom
Eryx-Z:fix/server-none-close-segfault

Conversation

@Eryx-Z

@Eryx-Z Eryx-Z commented Oct 16, 2026

Copy link
Copy Markdown

Summary

uvloop.loop.Server(None) can be constructed from Python. Calling close() then segfaulted in _unref when discarding from self._loop._servers.

Guard _unref and close when _loop is None so this invalid usage does not terminate the interpreter.

Fixes #760

Test plan

  • After rebuild: from uvloop.loop import Server; Server(None).close() should not segfault

Server(None) is constructible from Python; close() then segfaulted in
_unref via self._loop._servers. Return early when _loop is missing so
invalid construction raises a clean error path instead of crashing.

Fixes MagicStack#760
@Eryx-Z

Eryx-Z commented Oct 17, 2026

Copy link
Copy Markdown
Author

Closing for now; may revisit later.

@Eryx-Z Eryx-Z closed this Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Directly constructed uvloop.loop.Server(None) segfaults in close()

1 participant