Destroying a Thread leaks the objects on its per-thread freelists

Abierto
#14,216 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
67/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp
Área
backend

Línea de trabajo

Read Thread::~Thread() in src/iocore/eventsystem/Thread.cc and the freelist operations in include/iocore/eventsystem/ProxyAllocator.h; the issue links to the relevant declarations in Thread.h and the plugin thread lifecycle in InkIOCoreAPI.cc. Trace how each per-thread allocator returns cached objects to its global allocator, then check existing tests for thread destruction and allocator behavior. Done when destroying a thread returns its cached objects for every ProxyAllocator it holds.

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

Descripción

Bug Event System Leak Threads

Each Thread holds about 30 ProxyAllocator freelists (eventAllocator, ioAllocator, INKContAllocator, httpSMAllocator, ...), declared in Thread.h#L180-L211. THREAD_FREE pushes freed objects onto the freeing thread's list, up to proxy.config.allocator.thread_freelist_size (default 512) per allocator, before it starts returning them to the global allocator (ProxyAllocator.h#L106-L120).

ProxyAllocator has no destructor (ProxyAllocator.h#L45), and Thread::~Thread() drains only the IOBuffer block caches (Thread.cc#L47-L49). When a Thread is destroyed, whatever is still on its other freelists is never handed back to the global allocators and is leaked.

Event threads live for the life of the process, so this matters mainly for threads that are created and destroyed repeatedly. TSThreadCreate()/TSThreadInit() followed by TSThreadDestroy() (InkIOCoreAPI.cc#L215) is the main case: a plugin thread that frees API objects (continuations, IOBuffers, MIME handles) leaks up to the watermark of each allocator it used, on every destroy.

Suggested fix: drain every ProxyAllocator back to its global allocator in ~Thread, the way iobuf_thread_cache_drain() already does for ioBufCache.


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.