Merged
fix(machine): Fix the incorrect memory pool free #5394
W4termyAdd on Aug 11
fix(machine): Fix the incorrect memory pool free #5394
Merged
W4termyAdd on Aug 11
W4termy
W4termyCollaborators
Aug 11
使用bundle能力进行aicore-error单算子复现时,值依赖算子下,静态算子会让两个 map 始终为空(GetOrCopy 在 hostCtrlCache为空时提前返回,GetOrAllocCellMatch 在 bytes == 0时提前返回),析构中的循环一次都不会执行。
修复:去掉 ~KernelBundleDevCache() 中的 free,仅清空两个 map。设备内存的释放行为不变。
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for W4termy's contribution.)
W4termyW4termyCollaborators
Aug 11 Created pull request, commit 33149634
atomgit-bot
atomgit-bot
Aug 11 Comments:

变更摘要

此 PR 修复了 KernelBundleDevCache 析构函数中错误的设备内存释放逻辑。由于静态对象 DevMemoryPool 的析构顺序在 KernelBundleDevCache 之前,其 DestroyPool() 已先行释放所有内存块;析构函数中再次调用 Free 将命中空的 addrToBlock_ 并触发 FREE_FAILED。修复方案是移除 ~KernelBundleDevCache() 中对 cache_ 和 cellMatchCache_ 的显式 Free 调用,仅保留 clear() 清空映射表,设备内存的实际释放完全交由 DevMemoryPool 在进程退出时统一处理。

主要改动

  • 移除析构函数中的 devMem.Free() 调用:在 ~KernelBundleDevCache() 中删除了对 cache_ 各值以及 cellMatchCache_ 各 addr 字段的 Free 操作,仅保留两个 map 的 clear(),避免因 DevMemoryPool 已先析构而导致的重复释放错误。
  • 更新析构函数注释:新增注释说明不在此处释放的原因——DevMemoryPool 作为静态对象先于当前对象销毁,其 DestroyPool() 已释放所有块,再次释放会命中空 addrToBlock_ 并报 FREE_FAILED。
  • 更新头文件生命周期注释:将 GetOrCopy 和 GetOrAllocCellMatch 的返回指针生命周期描述从"Freed only in the destructor at exit"改为"Held until process exit",并更新类级注释,明确设备内存缓存在整个进程生命周期内有效,由 DevMemoryPool 在 teardown 时统一释放。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 11 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robot
CANN-robotCollaborators
Aug 11 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/pypto ✅ jason_yuan_ye, gaoxingwang (2/2) ✅ jason_yuan_ye (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

W4termy, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
Aug 11 Set xinweiliu,cam_bxh,dai-zhentao,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Aug 11 Set xinweiliu,cam_bxh,dai-zhentao,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Aug 11 Added label: cann-cla/yes
W4termyW4termyCollaborators
Aug 11 Associated issue: [Bug-Report|缺陷反馈]: 使用离线bundle功能进行aicore-error单算子复现过程中会有异常抛出
W4termyW4termyCollaborators
Aug 11 Modify description of pull request
W4termy
W4termyCollaborators
Aug 11 Comments:

compile

likedislike
W4termyW4termyCollaborators
Aug 11 Pre merge succeeded (commit_id: e1b741b761ed81bfe7ec6af2bec9fda4c574d640)
CANN-robotCANN-robotCollaborators
Aug 11 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Aug 11 Comments:

流水线任务触发成功
任务链接 [e312521643344226b2e2089a88b4a2e2][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
UT_Test_Py3_ninja_simulation ✅ SUCCESS
UT_Test_Py3_ninja ✅ SUCCESS
UT_Test_Cpp_make_gnu_part_1 ✅ SUCCESS
UT_Test_Cpp_make_gnu_part_2 ✅ SUCCESS
UT_Test_Cpp_make_gnu_part_3 ✅ SUCCESS
UT_Test_Cpp_make_clang_part1 ✅ SUCCESS
UT_Test_Cpp_make_clang_part2 ✅ SUCCESS
UT_Test_Cpp_make_clang_part3 ✅ SUCCESS
UT_Test_kirinx90 ✅ SUCCESS
UT_Test_kirin9030 ✅ SUCCESS
UT_Test_report ✅ SUCCESS >>>>>
PreSmoke_A900 ✅ SUCCESS >>>>>

[2026-08-11 17:23:31]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Aug 11 Comments:

流水线任务触发成功
任务链接 [64b4b6d9bcb547e9842460763e238de0][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Pr ✅ SUCCESS
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_codestyle ✅ SUCCESS >>>>>
codecheck_precommit ✅ SUCCESS >>>>>
StaticCheck_md ✅ SUCCESS

[2026-08-11 16:57:00]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Aug 11 Comments:

流水线任务触发成功
任务链接 [0b65cd9a5f3b4d5597900516aede25c4][流水线指导]

任务名称状态日志下载链接
get_pr_file ✅ SUCCESS
static-check ✅ SUCCESS
compile ✅ SUCCESS

[2026-08-11 17:24:08]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Aug 11 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 11 Added label: ci-pipeline-passed
袁野
袁野Collaborators
Aug 13 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 13 Added label: approved
gaoxingwang
gaoxingwangCollaborators
Aug 14 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Aug 14 Added label: lgtm
CANN-robotCANN-robotCollaborators
Aug 14 Closed associated issue
CANN-robotCANN-robotCollaborators
Aug 14 Merged pull request