Two event senders pass a payload type their receivers don't declare

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

Maintainer thường phản hồi trong vòng 2 ngày

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

Đánh giá

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

Hướng nghiên cứu

Start with the cited event contract in include/iocore/eventsystem/Continuation.h, then inspect the send and receive sites in src/iocore/aio/AIO.cc, src/iocore/cache/CacheVC.cc, and src/iocore/net/UnixNetVConnection.cc. Check the direct handleEvent(AIO_EVENT_DONE, nullptr) callers before changing the CacheVC handler parameter. Done means the AIO handler accepts its actual payload type and the three net callbacks pass NetVConnection* as documented.

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

Mô tả

Bug Cache Event System Network

ContinuationHandler converts an event's void* payload to the handler's declared data type with a static_cast. The contract on invoke and on Continuation::handler is that the payload was converted to void* from exactly that type, not from a pointer to a derived class (Continuation.h#L173, #L250). Two senders break it.

AIO completion to CacheVC::handleReadDone

AIOCallback::io_complete sends AIO_EVENT_DONE with this, an AIOCallback* (AIO.cc#L105). CacheVC::handleRead binds CacheVC::handleReadDone(int, Event *) as the receiving handler (CacheVC.cc#L554, CacheVC.cc#L363), so the AIOCallback* is cast to Event*. The parameter is unused, so nothing reads through the wrong type today.

Net VC callbacks

NET_EVENT_ACCEPT and NET_EVENT_OPEN are documented to carry a NetVConnection * (NetProcessor.h#L53, #L106), and receivers such as HttpSessionAccept do static_cast<NetVConnection *>(data) (HttpSessionAccept.cc#L101). UnixNetVConnection passes this directly, so the void* comes from a UnixNetVConnection* (or SSLNetVConnection*), not a NetVConnection* (UnixNetVConnection.cc#L1048, #L1050, #L1240). This works only because NetVConnection is the first base of UnixNetVConnection (P_UnixNetVConnection.h#L53) and so sits at the same address. Reordering the bases, or adding a polymorphic base in front, would hand receivers a wrong pointer.

Suggested fix

  • Pass static_cast<NetVConnection *>(this) in the three net callbacks.
  • Declare handleReadDone's data parameter as AIOCallback * (or void *), since it receives AIO completions, and check the direct handleEvent(AIO_EVENT_DONE, nullptr) callers still match.

generated with Claude Opus 5.5 by Josiah VanderZee

Ngôn ngữ chính
C++
Star
2k
Fork
903
Merge trung bình
4 ngày 4 giờ
Pull request đã merge (30 ngày)
135

Chuẩn bị môi trường

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.

Issue khác của apache/trafficserver

Tất cả issue của apache/trafficserver

Issue tương tự

Thêm issue về C++

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.