已合并
【PR】: Error Message相关bugfix修复 #2960
guo-yanjun创建于 6月18日
【PR】: Error Message相关bugfix修复 #2960
已合并
guo-yanjun创建于 6月18日
guo-yanjun成员
6月18日

Pull Request

描述

Error Message相关bugfix修复:
去掉[]、标点符号修改、无用错误码删除、修改参数打出实际入口传入参数名、安全函数memcpy_s确认问题修改

变更类型

请选择本次引入的变更类型:

关联的Issue

如何测试

UT测试、ErrorMessage打印测试

核对清单

其他信息

在此添加任何其他关于本次 PR 的说明。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 guo-yanjun 的贡献)
Gguo-yanjun成员
6月18日 添加了label:enhancement
Gguo-yanjun成员
6月18日 创建了 pull request,commit 895ded42
CANN-robotCANN-robot成员
6月18日 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
6月18日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月18日 评论:

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/runtime Reyn52166, 侯延保 (2/2) Reyn52166 (1/1)
src/acl Reyn52166, 侯延保 (2/2) Reyn52166 (1/1)
src/dfx/error_manager/error_code.json ycm0028, 侯延保 (2/2) ycm0028 (1/1)
src/runtime 侯延保, Reyn52166 (2/2) Reyn52166 (1/1)
tests/ut/acl Reyn52166, 侯延保 (2/2) Reyn52166 (1/1)
tests/ut/runtime Reyn52166, 侯延保 (2/2) Reyn52166 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
guo-yanjun成员
6月18日 评论:

/compile

likedislike
Gguo-yanjun成员
6月18日 update merge request[project id: 8810053, iid: 2960, commit_id: 207ca2cbd9c3d15eca43682ff8a92dc7c36ff6de] virtual merging success
CANN-robotCANN-robot成员
6月18日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月18日 评论:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
UT_Test_acl ✅ SUCCESS >>>>>
UT_Test_rts_v201 ✅ SUCCESS >>>>>
UT_Test_rts_c ✅ SUCCESS >>>>>
UT_Test_rts_david ✅ SUCCESS >>>>>
UT_Test_rts_910b ✅ SUCCESS >>>>>
UT_Test_rts_common ✅ SUCCESS >>>>>
UT_Test_platform ✅ SUCCESS >>>>>
UT_Test_qs ✅ SUCCESS >>>>>
UT_Test_aicpusd ✅ SUCCESS >>>>>
UT_Test_tsd ✅ SUCCESS >>>>>
UT_Test_error_manager ✅ SUCCESS >>>>>
UT_Test_slog ✅ SUCCESS >>>>>
UT_Test_atrace ✅ SUCCESS >>>>>
UT_Test_msprof_part1 ✅ SUCCESS
UT_Test_msprof_part2 ✅ SUCCESS
UT_Test_adump ✅ SUCCESS >>>>>
UT_Test_mmpa ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>
UT_Test_rts_report ✅ SUCCESS >>>>>
UT_Test_msprof_report ✅ SUCCESS

[2026-06-18 15:45:17]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6月18日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Check_Pr ✅ SUCCESS
codecheck_style ✅ SUCCESS >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS

[2026-06-18 15:33:43]    CI执行结束

likedislike
CANN-robotCANN-robot成员
6月18日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月18日 添加了label:ci-pipeline-passed
atomgit-bot
atomgit-bot
6月18日 评论:

Now I have thoroughly reviewed all 14 changed files. Let me compile my findings.

变更摘要

This PR focuses on Error Message related bugfixes, including removing [] brackets from error message templates, punctuation corrections, deleting the unused error code EE1008, fixing memcpy_s error reporting to use hex-formatted pointer addresses instead of string concatenation, and correcting the FillAttrValue function to use the caller's funcName parameter instead of __func__. It also adds new unit test cases for memcpy_s/strcpy_s failure paths.

主要改动

  • Error Message 格式修正(去括号/标点): 在 error_code.jsonerror_manager.c 中,将 "Value [%s] for [%s]""Argument [%s] must not be null" 等模板中的 [] 括号移除;EH0012 消息中 "failed, Parameter" 改为 "failed. Parameter"(逗号改句号)。相关的单元测试期望字符串同步更新。

  • 删除无用错误码 EE1008: 从 error_code.json(RTS Errors 中 Execution_Error_Load_OP_Kernel)、error_code_meta.h(X 宏定义)和 rt_log.hErrorCode 枚举)中完全移除 EE1008,相关的测试代码和引用一并清理。

  • memcpy_s/strcpy_s 错误报告重构: 在 tensor_data_transfer.cppqueue.cppacl.cppgroup.cppmemory.cpp 中,将 extendInfo 从字符串拼接方式("src=" + std::to_string(...))改为 std::stringstream 以十六进制格式输出指针地址(如 src=0x...),使错误信息更便于定位内存问题。同时将 memcpy_s 的 count/destMax 计算提取为独立变量以提高可读性。

  • group.cppFillAttrValuefuncName 修复: ReportInputError 调用的第一个参数从 __func__(始终为 "FillAttrValue")修正为函数参数 funcName,使错误报告能正确显示调用方 ACL API 的函数名。

  • 新增单元测试: 在 acl_common_unittest.cpp 中新增 aclsysGetVersionStr_CopyVersionFailed 测试覆盖版本字符串长度等于 ACL_PKG_VERSION_MAX_SIZEstrcpy_s 失败的场景;在 acl_runtime_unittest.cpp 中新增 aclrtGetGroupInfoDetail_Fail_MemcpySecurecRangeaclrtGetBufUserData_failed_when_memcpy_returns_erroraclrtSetBufUserData_failed_when_memcpy_returns_error 测试覆盖 memcpy_s 返回错误的路径。


逐文件审查确认

  • src/acl/acl_tdt_channel/tensor_data_transfer.cpp — no issues
  • src/acl/acl_tdt_queue/queue.cpp — no issues
  • src/acl/aclrt_impl/acl.cpp — no issues
  • src/acl/aclrt_impl/group.cpp — no issues
  • src/acl/aclrt_impl/memory.cpp — no issues
  • src/dfx/error_manager/error_code.json — no issues
  • src/runtime/core/inc/common/error_code_meta.h — no issues
  • src/runtime/core/inc/common/rt_log.h — no issues
  • src/runtime_compact/c_base/src/error_manager.c — no issues
  • tests/ut/acl/testcase/acl_common_unittest.cpp — no issues
  • tests/ut/acl/testcase/acl_runtime_unittest.cpp — no issues
  • tests/ut/acl/testcase_c/acl_rt_unittest.cpp — no issues
  • tests/ut/runtime/runtime/test/rt_error_code_test.cc — no issues
  • tests/ut/runtime/runtime_c/testcase/c_base/error_manager_test.cc — no issues
likedislike
atomgit-bot
atomgit-bot
6月18日 评论:

代码审查

All EE1008 references are cleanly removed from the entire codebase. The cleanup is thorough.

审查总结

本次审查覆盖了全部 14 个变更文件,逐文件审查结论如下:

文件 审查结论
src/acl/acl_tdt_channel/tensor_data_transfer.cpp 无问题:提取 count 变量、新增 <sstream>、日志格式改进均正确
src/acl/acl_tdt_queue/queue.cpp 无问题:日志格式改进正确
src/acl/aclrt_impl/acl.cpp 无问题:新增 <cstdint> 用于 uintptr_t、日志格式改进正确
src/acl/aclrt_impl/group.cpp 无问题:__func__funcName 修复了入口函数名打印问题、日志格式改进正确
src/acl/aclrt_impl/memory.cpp 无问题:提取 srcAddr/destAddr/destMax 变量为纯重构,逻辑不变
src/dfx/error_manager/error_code.json 无问题:EE1008 删除、EH* 消息去括号、EH0012 逗号改句号均一致
src/runtime/core/inc/common/error_code_meta.h 无问题:EE1008 X-macro 已删除
src/runtime/core/inc/common/rt_log.h 无问题:EE1008 枚举值已删除
src/runtime_compact/c_base/src/error_manager.c 无问题:EH* 消息去括号、注释同步更新;EK0001 保留方括号为预存差异,非本次引入
tests/ut/acl/testcase/acl_common_unittest.cpp 无问题:新增测试覆盖 strcpy_s 失败路径
tests/ut/acl/testcase/acl_runtime_unittest.cpp P3×2:两个新增测试依赖 memcpy_s(dest,0,src,0) 的实现定义行为
tests/ut/acl/testcase_c/acl_rt_unittest.cpp 无问题:断言消息同步去括号
tests/ut/runtime/runtime/test/rt_error_code_test.cc 无问题:EE1008 相关测试代码已清理
tests/ut/runtime/runtime_c/testcase/c_base/error_manager_test.cc 无问题:断言消息同步去括号

发现统计:P0: 0, P1: 0, P2: 0, P3: 2

整体风险评估:低风险。主体变更为错误消息格式优化(去括号、标点修正)、EE1008 错误码清理、以及 memcpy_s 调用前提取变量的纯重构。两个 P3 发现均针对新增单元测试中 memcpy_s(dest,0,src,0) 返回值依赖实现定义行为导致的潜在脆弱性,不影响生产代码正确性。

类型 数量
🔴 阻塞 0
🟡 建议 2

💬 仅评论

likedislike
atomgit-bot
atomgit-bot6月18日进行代码检视1
tests/ut/acl/testcase/acl_runtime_unittest.cpp
@@ -6230,0 +6264,4 @@
6264+ Return(RT_ERROR_NONE)));
6265+ 
6266+ auto ret = aclrtSetBufUserData(mbuf, data, 0U, sizeof(privateData));
6267+ EXPECT_EQ(ret, ACL_ERROR_FAILURE);
atomgit-bot
atomgit-bot6月18日评论:

🔵 Low Priority

aclrtSetBufUserDataImpl(memory.cpp:1736-1737)中,当 offset=96, bufSize=96destMax = 96 - 96 = 0,随后调用 memcpy_s(destAddr, 0, dataPtr, 0),即 destMax 和 count 均为 0。新增测试 aclrtSetBufUserData_failed_when_memcpy_returns_error(acl_runtime_unittest.cpp:6257)通过传入 size=0U, offset=sizeof(privateData)=96 触发此路径,并期望返回 ACL_ERROR_FAILURE

与 GetBuf 测试同理,memcpy_s(dest, 0, src, 0) 的行为是实现定义的:C11 Annex K 在 count=0 时允许返回 EOK,而部分 securec 实现会对 destMax=0 报告约束错误。此测试不具备跨平台可移植性。

触发条件:同 GetBuf 测试,在 memcpy_s(dest, 0, src, 0) 返回 EOK 的平台上运行此测试。

建议:使用 mock 控制 memcpy_s 返回值,或改用 count > destMax > 0 的参数组合来可靠触发 memcpy_s 错误;同时在测试注释中说明当前 securec 对 destMax=0 的处理行为。

likedislike
atomgit-bot
atomgit-bot6月18日进行代码检视1
tests/ut/acl/testcase/acl_runtime_unittest.cpp
@@ -6230,0 +6251,4 @@
6251+ Return(RT_ERROR_NONE)));
6252+ 
6253+ auto ret = aclrtGetBufUserData(mbuf, data, 0U, 0U);
6254+ EXPECT_EQ(ret, ACL_ERROR_FAILURE);
atomgit-bot
atomgit-bot6月18日评论:

🔵 Low Priority

aclrtGetBufUserDataImpl(memory.cpp:1694)中,当 size=0 时调用 memcpy_s(dataPtr, 0, srcAddr, 0),即 destMax 和 count 均为 0。新增测试 aclrtGetBufUserData_failed_when_memcpy_returns_error(acl_runtime_unittest.cpp:6244)通过传入 size=0U 触发此路径,并期望返回 ACL_ERROR_FAILURE

然而,C11 Annex K 规定当 count=0memcpy_s 应返回 0(EOK),无需执行拷贝。部分实现(如某些版本的 securec)可能对 destMax=0 进行约束检查并返回错误。该测试的正确性依赖于具体 memcpy_s 实现的行为,不具备跨平台可移植性。如果 memcpy_s 实现返回 EOK,此测试将失败。

触发条件:在 memcpy_s(dest, 0, src, 0) 返回 EOK 而非错误的平台上运行此测试。

建议:使用 mock 控制 memcpy_s 返回值,或改用 count > destMax > 0 的参数组合来可靠触发 memcpy_s 错误;同时在测试注释中说明当前 securec 对 destMax=0 的处理行为。

likedislike
Gguo-yanjun成员
6月18日 解决了最后一个问题
leihuan1成员
6月18日 评论:

/approve

likedislike
guo-yanjun成员
6月22日 评论:

/compile

likedislike
Gguo-yanjun成员
6月22日 update merge request[project id: 8810053, iid: 2960, commit_id: d9e1765583afd7f041222841981264b20321e200] virtual merging success
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-passed
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
UT_Test_acl ✅ SUCCESS >>>>>
UT_Test_rts_v201 ✅ SUCCESS >>>>>
UT_Test_rts_c ✅ SUCCESS >>>>>
UT_Test_rts_david ✅ SUCCESS >>>>>
UT_Test_rts_910b ✅ SUCCESS >>>>>
UT_Test_rts_common ✅ SUCCESS >>>>>
UT_Test_platform ✅ SUCCESS >>>>>
UT_Test_qs ✅ SUCCESS >>>>>
UT_Test_aicpusd ✅ SUCCESS >>>>>
UT_Test_tsd ✅ SUCCESS >>>>>
UT_Test_error_manager ✅ SUCCESS >>>>>
UT_Test_slog ✅ SUCCESS >>>>>
UT_Test_atrace ✅ SUCCESS >>>>>
UT_Test_msprof_part1 ✅ SUCCESS
UT_Test_msprof_part2 ✅ SUCCESS
UT_Test_adump ✅ SUCCESS >>>>>
UT_Test_mmpa ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>
UT_Test_rts_report ✅ SUCCESS >>>>>
UT_Test_msprof_report ✅ SUCCESS

[2026-06-22 09:41:40]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Check_Pr ✅ SUCCESS
codecheck_style ✅ SUCCESS >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS

[2026-06-22 09:36:17]    CI执行结束

likedislike
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-passed
houyanbao成员
6月22日 评论:

/lgtm

likedislike
ycm0028成员
6月22日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
6月22日 添加了label:lgtmapproved
CANN-robotCANN-robot成员
6月22日 合入了pull request