Constructing a protocol_view from a valueless protocol is undiagnosed, and calls through it hit a null function pointer
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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.
- Lenguaje dominante
- C++
- Estrellas
- 12
- Forks
- 4
- Merge medio
- 1 d 11 h
- PR fusionados (30 d)
- 15
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de jbcoe/cc-protocol
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
jbcoe/cc-protocol#507 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
jbcoe/cc-protocol#455 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
jbcoe/cc-protocol#407 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
jbcoe/cc-protocol#194 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
jbcoe/cc-protocol#513 ·
Los mantenedores suelen responder en 1 día
Todos los issues de jbcoe/cc-protocol
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
itinance/react-native-fs#1270 ·
-
clang:frontend clang:openmp crash
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
llvm/llvm-project#245442 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
ai_p1 comp-sql-syntax
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
ClickHouse/ClickHouse#133888 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-2 días Aptitud para principiantes 65/100