MagicStack / MagicStack/uvloop

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

Đang mở
#760 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Cython
Star
11.9k
Fork
616
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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

```python
from uvloop.loop import Server

server = Server(None)
server.close()
```

```console
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:

```text
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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với các đường dẫn Server.close và Server._unref được xác định trong uvloop/loop.c, sau đó tái hiện lỗi bằng đoạn mã Python sử dụng Server(None). Theo dõi đường dẫn close dưới ASan và xác minh rằng trình tái hiện phát sinh một ngoại lệ Python hoặc hoàn tất theo cách khác mà không kết thúc trình thông dịch.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend, networking
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
68/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.