CacheVC zeroes its VIO and other non-trivial members with memset

Abierto
#14,223 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
69/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp
Área
backend

Línea de trabajo

Read the constructor in src/iocore/cache/CacheVC.cc around lines 160–165, free_CacheVC in src/iocore/cache/P_CacheInternal.h around line 243, and the VIO member in src/iocore/cache/CacheVC.h around line 258. Replace the raw reset of the region with member assignments or a value-initialized sub-struct, accounting for all members in that region. Done means construction and recycling reset those members without memset over non-trivial objects.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Cache Cleanup

CacheVC resets "region C", everything from vio to the end of the object, with a raw memset. This happens both in the constructor (CacheVC.cc#L160-L165) and on every recycle in free_CacheVC (P_CacheInternal.h#L243). The region starts with a VIO (CacheVC.h#L258). A VIO contains a Ptr<ProxyMutex> and a MIOBufferAccessor, so it isn't trivially copyable. The region also contains save_handler. The reinterpret_cast<void *> hides the -Wclass-memaccess warning that would otherwise flag this. The region's size is computed with a null-pointer member-offset trick on a non-standard-layout class.

Writing over those objects with memset is undefined behavior. In practice it works today: free_CacheVC clears vio.buffer and vio.mutex before the memset, a null Ptr is all-zero bits, and in the constructor the members were just default-initialized to the same state. It breaks silently, though, as soon as any member in that region gets a non-zero default or owns a resource, for example a new field in VIO.

Suggested fix: reset the region by assigning the members (or a value-initialized sub-struct) instead of memset, so new members get correct reset behavior from the compiler.


generated with Claude Opus 5.5 by Josiah VanderZee

Lenguaje dominante
C++
Estrellas
2k
Forks
903
Merge medio
4 d 4 h
PR fusionados (30 d)
135

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/trafficserver

Todos los issues de apache/trafficserver

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.