Constructing a protocol_view from a valueless protocol is undiagnosed, and calls through it hit a null function pointer
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
A moved-from protocol has object_ == nullptr and vtable_ == &null_vtable,
whose member entries are null function pointers. Calling a member function on
it directly is caught in debug builds: method_thunk::operator() asserts
!valueless_after_move() before dispatching.
Since #244 and #272 a protocol_view<I> or protocol_view<const I> constructs
implicitly from a protocol<I, A>&, copying object_ and vtable_. Nothing
checks the source, so a valueless protocol converts silently, and the thunk
assert is if constexpr (is_protocol_v<ProtocolType>), so it is compiled out
for views. A member call through such a view calls a null function pointer with
no diagnostic, even in a debug build.
protocol<Shape> a{Circle{}};
protocol<Shape> b = std::move(a); // a is valueless
protocol_view<const Shape> v = a; // accepted; comment says "Precondition: p is not valueless"
v.area(); // release: null call; debug: also null call
The from-protocol constructors document the precondition in a comment
(protocol.hh, both protocol_view specializations) but do not enforce it.
Suggested fix, small enough for one PR:
assert(!p.valueless_after_move())in the two from-protocol constructors.- Drop the
is_protocol_vgate inmethod_thunkand assertobject_ != nullptr
instead, which covers protocol and view alike. A view'sobject_is otherwise
never null. - A death test for each path.
#208 settled the direct-call case as a precondition violation diagnosed by an
assert in debug builds; this extends the same contract to views. Raised in the
review of #272, where it was agreed to be out of scope there but worth fixing.
- Ngôn ngữ chính
- C++
- Star
- 12
- Fork
- 4
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của jbcoe/cc-protocol
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
jbcoe/cc-protocol#507 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
jbcoe/cc-protocol#455 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jbcoe/cc-protocol#407 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jbcoe/cc-protocol#194 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
jbcoe/cc-protocol#513 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của jbcoe/cc-protocol
Issue tương tự
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS poolsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
CefRequestContext::ClearHttpCache crashes with a null callback, though the callback is optionalĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
chromiumembedded/cef#4376 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
itinance/react-native-fs#1270 ·
-
area-CodeGen-coreclr untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotnet/runtime#138181 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
yuaotian/antigravity-proxy#181 ·