已关闭
[Bug-Report|缺陷反馈]: 全部 example 示例的 ASD_STATUS_CHECK 宏失败路径 exit(-1) 不清理资源 #99
syy_3597创建于  15 天前关闭于  14 天前
syy_3597
15 天前 创建

Describe the current behavior / 问题描述

以 example/A2/BLAS/cgemv/example_cgemv.cpp:20 为代表,全部 example 使用如下宏:

#define ASD_STATUS_CHECK(err)                                  \
    do {                                                       \
        AsdSip::AspbStatus err_ = (err);                       \
        if (err_ != AsdSip::ErrorType::ACL_SUCCESS) {          \
            std::cout << "Execute failed." << std::endl;       \
            exit(-1);                                          \
        } else {                                               \
            std::cout << "Execute successfully." << std::endl; \
        }                                                      \
    } while (0)

失败路径直接 exit(-1),不做任何资源清理:

  • 已创建的 asdBlasHandle 不销毁(泄漏 plan 及 device 内存)
  • aclrtStream 不销毁
  • aclrtMalloc 分配的 device 内存不释放
  • aclDestroyTensor / aclFinalize 均不执行

示例代码是用户集成的主要参考,该模式会被直接复制到用户生产代码中,失败即泄漏。

Impact / 影响

示例自身的健壮性与示范作用问题,不影响库本体;但会向用户传递不良实践。

Suggested fix / 修复建议

失败路径补 asdBlasDestroy / aclrtDestroyStream / aclrtFree / aclFinalize 等清理,或改为错误码逐层返回 + main 统一清理的结构。

Environment / 环境信息

  • 位置: example/A2/ 下全部示例(example_cgemv.cpp:20 等)
likedislike
east_yang成员
15 天前 评论:

感谢您的反馈,当前@east_yang跟踪处理中。

likedislike
Ssyy_3597
15 天前 关联了pull request:fix: 修复代码审查发现的健壮性与文档问题(#96-#105)
CANN-robotCANN-robot成员
14 天前 关闭了 issue
CANN-robotCANN-robot成员
14 天前 添加了label:resolved