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

Aberta
#14,207 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
65/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
cpp
Domínio
backend, networking

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
C++
Estrelas
2k
Forks
903
Merge médio
4d 4h
PRs com merge (30d)
135

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de apache/trafficserver

Todas as issues de apache/trafficserver

Issues semelhantes

Mais issues de C++

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.