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

Aperta
#14,216 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
67/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
C++
Stelle
2k
Fork
903
Merge medio
4g 4h
PR unite (30g)
135

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/trafficserver

Tutte le issue di apache/trafficserver

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.