Closed
[Bug-Report|缺陷反馈]: HcclAllGatherV 单 rank 场景成功返回时泄漏 OpParam 临时内存 #103
.xyc11Add on  May 5Closed at  Jun 4
.xyc11
.xyc11
May 5 Create

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

在 hccl/src/ops/all_gather_v/all_gather_v_op.cc:156 中,AllGatherVOutPlace 通过 malloc(sizeof(OpParam) + varMemSize) 分配 paramMem,并用
placement new 构造 OpParam。

但当 userRankSize == 1 时,代码调用 SingleRankProc 后直接 return HCCL_SUCCESS,没有执行后面的

paramPtr->~OpParam(); 
free(paramMem);

因此每次单 rank 调用都会泄漏一次临时内存。

相关代码点:

  • 分配:all_gather_v_op.cc: 156
  • 单 rank 提前返回:all_gather_v_op.cc: 200-203
  • 释放只在正常多 rank 路径:all_gather_v_op.cc: 214-215

Environment / 环境信息 (Mandatory / 必填)

master分支

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

  1. 在现有 ST/sim 测试中新增一个 HcclAllGatherV 单 rank 用例,TopoMeta topoMeta{{{0}}}。
  2. 初始化 SimWorld::Global()->Init(topoMeta, DevType::DEV_TYPE_950)。
  3. 创建单个 rank 的 comm、stream、sendBuf、recvBuf,设置 recvCounts = {N}、recvDispls = {0}。
  4. 循环调用 HcclAllGatherV(sendBuf, N, recvBuf, recvCounts.data(), recvDispls.data(), dataType, comm, stream)。
  5. 观察进程内存或用 ASan/Valgrind 检测,会看到 AllGatherVOutPlace 中分配的 paramMem 未释放。

Describe the expected behavior / 预期结果 (Mandatory / 必填)

单 rank 场景应成功完成本地拷贝,并在返回前释放 paramMem、析构 OpParam;重复调用不应导致进程内存持续增长。

同重现步骤。

Special notes for this issue/备注 (Optional / 选填)

likedislike
LLeewisCollaborators
May 6 associated Kanban: HCCL
LeewisCollaborators
May 6 Comments:

感谢对于社区的关注与反馈,当前issue所提问题我们尽快明确修复。

likedislike
a1847373419
a1847373419
May 6 Comments:

当前问题已明确,后续会尽快解决上库

likedislike
LLeewisCollaborators
May 6 Assign a1847373419 as responsible person
Zzsj1998
May 11 Associated pull request
Zzsj1998
May 11 Deleted associated pull request: fix bug:all_gather_v_op.cc存在疑似内存泄露风险
LLeewisCollaborators
Jun 1 Assign z00850967 as responsible person, remove original responsible person: a1847373419
CANN-robotCANN-robotCollaborators
Jun 4 Close issue
CANN-robotCANN-robotCollaborators
Jun 4 Added label: resolved
LLeewisCollaborators
Sep 2 removed Kanban: HCCL