MagicStack / MagicStack/uvloop
Directly constructed `uvloop.loop.Server(None)` segfaults in `close()`
Nobody has claimed this yet.
- Dominant language
- Cython
- Stars
- 11.9k
- Forks
- 615
- PR merge metrics
- No merged PRs in 30d
Description
Summary
uvloop.loop.Server(None) constructs an object, but calling close() on it terminates the interpreter.
I found this while fuzzing Python C extension modules.
I realize this is not a realistic input or usage pattern, but I would expect a Python exception rather than a process crash.
Versions
uvloop 0.22.1, CPython 3.12.3, Debian 12 x86_64, glibc 2.36
Reproducer
from uvloop.loop import Server
server = Server(None)
server.close()
Segmentation fault (core dumped)
ASan/UBSan result
I built uvloop 0.22.1 from source with Clang 18 using ASan and UBSan instrumentation.
ASan reports a read from address 0x158 on the Server.close() path:
AddressSanitizer:DEADLYSIGNAL
ERROR: AddressSanitizer: SEGV on unknown address 0x000000000158
The signal is caused by a READ memory access.
Hint: address points to the zero page.
#0 PyType_IsSubtype
#1 CPython set operation
#2 __Pyx_PySet_Discard uvloop/loop.c:194862:17
#3 Server._unref uvloop/loop.c:160673:15
#4 Server.close uvloop/loop.c:161676:19
SUMMARY: AddressSanitizer: SEGV in PyType_IsSubtype
The sanitizer process exits with code 134 after ASan aborts.
UBSan did not emit a separate diagnostic before the ASan failure.
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.
Research direction
Start with the Server.close and Server._unref paths identified in uvloop/loop.c, then reproduce the failure with the Python snippet using Server(None). Trace the close path under ASan and verify that the reproducer raises a Python exception or otherwise completes without terminating the interpreter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100