MagicStack / MagicStack/uvloop

start_tls: AssertionError if writing is paused

Đang mở
#564 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ả

First found in the CPython port of sslproto (see https://github.com/python/cpython/issues/109051 but disregard the title, it's not platform-specific), and it can be reproduced in uvloop.

Traceback

protocol.resume_writing() failed
protocol: <uvloop.loop.SSLProtocol object at 0x1033910c0>
transport: <TCPTransport closed=False reading=True 0x1098351c0>
Traceback (most recent call last):
  File "uvloop/handles/basetransport.pyx", line 96, in uvloop.loop.UVBaseTransport._maybe_resume_protocol
    run_in_context(
  File "uvloop/loop.pyx", line 101, in uvloop.loop.run_in_context
    return context.run(method)
  File "uvloop/sslproto.pyx", line 922, in uvloop.loop.SSLProtocol.resume_writing
    assert self._ssl_writing_paused
AssertionError

Simplest way to reproduce is to increase payload size in test_start_tls_server_1. Send will block and transport will request to pause writing. After start_tls(), the transport will attempt to resume the now-switched protocol, which was not aware it was ever supposed to be paused.

I commented further in the original bug with some notes. The CPython implementation is a bit different (it has a redundant buffering mechanism with a deque which I believe is unnecessary) but the fundamental issue is the same.

Question: what is the motivation for the extra flow control layer in SSLProtocol? It seems it was introduced in uvloop first. I suggested it can be removed and let the original protocol and original transport deal with flow control (which would also fix the bug). But it wouldn't be a good idea to remove it if it's solving a known problem.

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 tests/test_tcp.py, đặc biệt là test_start_tls_server_1, và tái hiện trường hợp payload lớn được mô tả trong issue. Sau đó kiểm tra uvloop/sslproto.pyx quanh SSLProtocol.resume_writing và start_tls để hiểu quá trình chuyển đổi kiểm soát luồng. Phần hoàn thành cần bao gồm một bản sửa đã được xác nhận cho assertion và một bài kiểm thử hồi quy bao quát trường hợp thao tác ghi bị tạm dừng trong khi khởi động TLS.

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
networking
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/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.