THREAD_ALLOC dereferences a null thread while THREAD_FREE falls back to the global allocator

Abierto Apto para principiantes
#14,217 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
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp
Área
backend

Línea de trabajo

Empieza por las macros THREAD_ALLOC, SAFE_THREAD_ALLOC y THREAD_FREE de include/iocore/eventsystem/ProxyAllocator.h (líneas 87–110). Compara su comportamiento con un thread nulo y revisa los puntos de llamada indicados en IOBuffer.cc, InkAPI.cc y cripts/unit_tests/main.cc. Se considera terminado cuando la asignación desde un thread no registrado ya no desreferencia un puntero nulo y una prueba adecuada cubre el fallback o el diagnóstico previsto.

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

Descripción

Bug Event System Threads

THREAD_ALLOC and THREAD_ALLOC_INIT expand to thread_alloc(::_a, _t->_a, ...) and dereference the thread pointer unconditionally (ProxyAllocator.h#L87-L88). The matching THREAD_FREE checks for a null thread and frees to the global allocator instead (ProxyAllocator.h#L109-L110), and SAFE_THREAD_ALLOC does the same for allocation (ProxyAllocator.h#L89).

Most callers pass this_thread() or this_ethread(), which is null on any OS thread not registered with the event system. Examples include new_MIOBuffer / new_IOBufferBlock (IOBuffer.cc#L171, IOBuffer.cc#L723), TSContCreate() (InkAPI.cc#L3844) and TSVConnCreate() (InkAPI.cc#L6426). Allocating from an unregistered thread crashes, but freeing the same object there works. Setting cmd_disable_pfreelist doesn't help either, because the macro still evaluates _t->_a. The cripts unit test has to register a fake EThread on main for this reason (cripts/unit_tests/main.cc#L41-L45).

Suggested fix: give THREAD_ALLOC the same null fallback as THREAD_FREE (i.e. make it SAFE_THREAD_ALLOC), or turn the null case into an ink_release_assert with a message, so a plugin calling these APIs from its own thread gets a diagnosable error rather than a segfault.


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.