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

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从include/iocore/eventsystem/ProxyAllocator.h(第87–110行)中的THREAD_ALLOC、SAFE_THREAD_ALLOC和THREAD_FREE宏开始。比较它们对null thread的处理行为,并检查IOBuffer.cc、InkAPI.cc和cripts/unit_tests/main.cc中提到的调用方。完成标准是:从未注册的thread进行分配时不再解引用空指针,并且有适当的测试覆盖预期的fallback或诊断。

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

描述

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

主要语言
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 摘要。