~EThread does not close its eventfd or pipe, leaking descriptors per TSThreadCreate/TSThreadDestroy

未关闭 适合新手
#14,199 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp, linux

调研方向

阅读 src/iocore/eventsystem/UnixEThread.cc 第 100–141 行附近的 eventfd/pipe 设置,以及 src/api/InkIOCoreAPI.cc 第 92 行和第 215 行附近的专用线程生命周期。检查描述符如何初始化,以及哪些值表示它们已打开,然后验证销毁时会关闭相应的描述符。反复创建和销毁插件线程后不再留下打开的描述符,即为完成。

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

描述

Bug Core Event System Leak Threads TS API

EThread(ThreadType, int) opens an eventfd (or, without eventfd, a pipe) for waking the thread (https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/src/iocore/eventsystem/UnixEThread.cc#L100-L122). ~EThread releases the thread mutex but never closes evfd or evpipe (https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/src/iocore/eventsystem/UnixEThread.cc#L132-L141).

Most event threads live for the whole process, but INKThreadInternal, which backs the plugin thread API, is constructed with EThread(DEDICATED, -1) (https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/src/api/InkIOCoreAPI.cc#L92), so every TSThreadCreate or TSThreadInit opens a descriptor (two for the pipe), and TSThreadDestroy deletes the object (https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/src/api/InkIOCoreAPI.cc#L215) without closing them. A plugin that creates and destroys threads repeatedly (for example plugins/experimental/magick, https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/plugins/experimental/magick/magick.cc#L111) leaks one descriptor per thread until it hits the fd limit.

Suggested fix: close evfd / evpipe[0..1] in ~EThread when they were opened. A dedicated thread may not need a wakeup descriptor at all.


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 摘要。