已关闭
[Bug-Report|缺陷反馈]: [Adump] 修复AI静态扫描复核接受的4项问题 #918
Lujialiang创建于  15 天前关闭于  12 天前
Lujialiang
15 天前 创建

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

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

在 CANN runtime 的 Adump 模块中,静态扫描复核确认以下 4 项问题需要处理:

  1. src/dfx/adump/adump/adx_dump_record.cppRecordDumpDataToDisk() 中,while (FileUtils::IsDiskFull(...)) 循环体无条件 return false,循环实际最多执行一次(扫描报告原始位置::308,当前源码对应 :329)。
  2. 同文件 StatsDataParsing() 中存在相同的 while + unconditional return 结构(扫描报告原始位置::630,当前源码对应 :659)。
  3. src/dfx/adump/adump/operator/operator_dumper.cppOperatorDumper(const DumpSetting&) 仅初始化 setting_,未初始化成员 stream_;另一个构造函数已将其初始化为 nullptr(扫描报告位置::40)。
  4. src/dfx/adump/adump/printf/dump_printf/dump_printf.cpp 中存在冗余条件 A || (!A && B),可等价化简为 A || B(扫描报告原始位置::817-818,当前源码对应 :782-783)。

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

  • Repository: cann/runtime(GitCode)
  • Component: src/dfx/adump
  • Static scan artifact: runtime-dev_result_20260825_reassessment.xlsx
  • Scan tool: TscanCode
  • Scan date: 2026-08-25
  • Hardware: 与具体 Ascend 型号无关,属于跨平台 C/C++ 源码静态问题;尚未报告运行时崩溃。

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

  1. 使用 TscanCode 对 CANN runtime 的 Adump 源码执行静态扫描。
  2. 检查上述 4 个文件及对应位置。
  3. 编译或执行相关 Adump 路径,覆盖磁盘空间不足、正常磁盘空间、未设置 RuntimeStream 以及不同 dump type/config flag 场景。

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

  • 磁盘空间检查使用与实际控制流一致的结构;若设计为立即失败,应使用 if,若设计为重试则应具备明确的等待、状态变化和重试上限。
  • 所有构造函数都应将 stream_ 初始化为 nullptr,避免未初始化句柄传入运行时接口。
  • 冗余布尔条件应在不改变短路语义的前提下简化。
  • 静态扫描不再报告上述 4 项问题,现有运行行为保持不变。

TscanCode 报告:

  • (adx_dump_record.cpp:308) (Warning) An unconditional 'break/return/goto' within a loop. It may be a mistake.
  • (adx_dump_record.cpp:630) (Warning) An unconditional 'break/return/goto' within a loop. It may be a mistake.
  • (operator_dumper.cpp:40) (Warning) Member variable 'OperatorDumper::stream_,' is not initialized in the constructor.
  • (dump_printf.cpp:817) (Information) Redundant condition: dumpHead.type==AdxDumpType::DUMP_TIMESTAMP. 'A || (!A && B)' is equivalent to 'A || B'

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

本 Issue 合并跟踪 reassessment 表中“复核处置动作”为“接受问题”的 4 项:2、3、4、7。建议先将两个单次磁盘检查循环改为 if,再补齐 stream_ 初始化,最后简化打印条件;修改后执行 Adump 相关 UT、编译和静态扫描回归。

likedislike
LLujialiang
15 天前 添加了label:bug-report
Lujialiang
15 天前 评论:

/assign

likedislike
CANN-robotCANN-robot成员
15 天前 将 Lujialiang 设为负责人
LLujialiang
15 天前 关联了pull request:fix: resolve adump static analysis findings (#918)
ykl999
ykl999成员
12 天前 评论:

Bug已修复,此issue关闭

likedislike
ykl999ykl999成员
12 天前 issue状态由 进行中 改变为 已解决
ykl999ykl999成员
12 天前 关闭了 issue
CANN-robotCANN-robot成员
12 天前 添加了label:resolved