已合并
fix: aclAppLog 超长日志改用截断而非丢弃整条日志(#555) #2850
GuoWenbo创建于 6月16日
fix: aclAppLog 超长日志改用截断而非丢弃整条日志(#555) #2850
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 GuoWenbo 的贡献)6月16日 添加了label:cann-cla/yes
CANN-robot
6月16日 评论:
6月16日 评论:
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 |
|---|---|---|
| include | ✅ 侯延保, 王涛 (2/2) | ✅ 王涛 (1/1) |
| repo-cann/runtime | ✅ 侯延保, 王涛 (2/2) | ✅ 王涛 (1/1) |
| src/acl | ✅ 侯延保, 王涛 (2/2) | ✅ 王涛 (1/1) |
| tests/ut/acl | ✅ 王涛, 侯延保 (2/2) | ✅ 王涛 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
GuoWenbo, thanks for your pull request. All authors of the commits have signed the CLA. 👍


6月16日 添加了label:ci-pipeline-running
CANN-robot
6月16日 评论:
6月16日 评论:
流水线任务触发成功
任务链接 [3a99b2331a66452db67bca62585d6e08][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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 | ✅ SUCCESS | >>>>> | |
| UT_Test_adump | ✅ SUCCESS | >>>>> | |
| UT_Test_mmpa | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> | |
| UT_Test_rts_report | ✅ SUCCESS | >>>>> |
[2026-06-16 10:03:24] CI执行结束


CANN-robot
6月16日 评论:
6月16日 评论:
流水线任务触发成功
任务链接 [2881c12f9f1d498f869ba0fd594f581a][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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-16 10:04:36] CI执行结束


6月16日 删除了label:ci-pipeline-running
6月16日 添加了label:ci-pipeline-passed
6月16日 添加了label:SC-SUCC
6月16日 添加了label:AscendC-SUCC
6月16日 添加了label:BUILD-SUCC
6月16日 添加了label:approved
6月16日 添加了label:lgtm
6月16日 合入了pull request
Pull Request
描述
修复 issue #555(同步自 master 分支 PR #2780)。
用户通过
ACL_APP_LOG/aclAppLog打印日志时,若格式化后的字符串总长度超过 1024 字节,会因vsnprintf_s在截断时返回 -1 而丢弃整条日志,仅输出一句不准确的aclAppLog call vsnprintf_s failed,用户看不到任何原始内容。本次变更:
src/acl/aclrt_impl/log.cpp:vsnprintf_s/sprintf_s改为vsnprintf_truncated_s/snprintf_truncated_s,超长时截断保留内容并正常落盘,不再丢弃整条日志。...[truncated]标记;标记连同结尾\0始终落在 1024 字节预算内,避免被下游 slog 二次截断。%n)时的aclAppLog format string is invalid错误提示。include/external/acl/acl_base_rt.h:补充aclAppLog1024 字节长度限制及截断标记说明。tests/depends/slog/inc/slog_stub_log_capture.h(新增)+slog_stub.cpp:以函数接口DlogStubGetLastLogMsg()暴露 stub 捕获的日志内容(vsnprintf_s并检查返回值),支撑截断标记的 UT 断言,规避 G.EXP.05-CPP / G.FUU.11 等规则。tests/ut/acl/testcase/acl_common_unittest.cpp:新增截断标记存在、最终落盘总长 < 1024、短日志不带标记、非法格式提示等用例。变更类型
关联的Issue
https://gitcode.com/cann/runtime/issues/555
如何测试
ascendcl_utest(bash tests/build_ut.sh --ut acl)。ascendcl_cpp_utest --gtest_filter='*aclAppLog*:*FormatStr*',确认:vsnprintf_s failed,按调用 level 落盘;...[truncated]标记,最终落盘总长 < 1024;format string is invalid;FormatStr行为不变。...[truncated],不再丢日志。核对清单
其他信息
本 PR 为 master 分支 PR #2780 向 9.1.0 分支的同步,代码改动完全一致。不改变
MAX_LOG_STRING(1024)上限本身,仅影响 ACL APP 日志路径(aclAppLog/aclAppLogWithArgs→aclAppLogImpl)。