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

未关闭
#14,216 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
67/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp
领域
backend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
C++
星标
2k
派生
903
平均合并
4 天 4 小时
30 天内合并 PR
135

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/trafficserver 的其他 Issue

查看 apache/trafficserver 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。