CacheVC zeroes its VIO and other non-trivial members with memset

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Read the constructor in src/iocore/cache/CacheVC.cc around lines 160–165, free_CacheVC in src/iocore/cache/P_CacheInternal.h around line 243, and the VIO member in src/iocore/cache/CacheVC.h around line 258. Replace the raw reset of the region with member assignments or a value-initialized sub-struct, accounting for all members in that region. Done means construction and recycling reset those members without memset over non-trivial objects.

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

描述

Cache Cleanup

CacheVC resets "region C", everything from vio to the end of the object, with a raw memset. This happens both in the constructor (CacheVC.cc#L160-L165) and on every recycle in free_CacheVC (P_CacheInternal.h#L243). The region starts with a VIO (CacheVC.h#L258). A VIO contains a Ptr<ProxyMutex> and a MIOBufferAccessor, so it isn't trivially copyable. The region also contains save_handler. The reinterpret_cast<void *> hides the -Wclass-memaccess warning that would otherwise flag this. The region's size is computed with a null-pointer member-offset trick on a non-standard-layout class.

Writing over those objects with memset is undefined behavior. In practice it works today: free_CacheVC clears vio.buffer and vio.mutex before the memset, a null Ptr is all-zero bits, and in the constructor the members were just default-initialized to the same state. It breaks silently, though, as soon as any member in that region gets a non-zero default or owns a resource, for example a new field in VIO.

Suggested fix: reset the region by assigning the members (or a value-initialized sub-struct) instead of memset, so new members get correct reset behavior from the compiler.


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