MallocAllocator does not check for allocation failure

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

维护者通常 2 天内回复

@umrndem 已经在做这个了。

开始于 2026年12月5日。

  • #14287 来自 @umrndem —— 未关闭

评估

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

调研方向

阅读include/tscore/Allocator.h,特别是第137–148行的MallocAllocator::alloc_void()和第343–345行的ClassAllocator::alloc()。将分配失败处理与src/tscore/ink_queue.cc中约第245行的ats_malloc和ats_memalign路径进行比较。完成标准是:分配失败时产生明确的内存不足错误,而不是继续使用空指针;该 issue 没有提到测试。

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

描述

Bug Core Good First Issue

With ENABLE_MALLOC_ALLOCATOR, Allocator is MallocAllocator (Allocator.h#L315-L325). MallocAllocator::alloc_void() returns the result of malloc or aligned_alloc without checking it, and calls madvise on it first (Allocator.h#L137-L148). ClassAllocator::alloc() then placement-news the object at the returned pointer (Allocator.h#L343-L345).

On allocation failure, the object is therefore constructed at nullptr, which is undefined behavior and normally a crash at some later, unrelated-looking point. The default freelist allocator gets its memory through ats_malloc/ats_memalign (ink_queue.cc#L245), which abort with a clear out-of-memory message. The malloc build should behave the same way.

Suggested fix: allocate through ats_malloc/ats_memalign in MallocAllocator::alloc_void(), or check the result and abort with an out-of-memory error.


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