已合并
[feat] 完善 ACLRTC `ResourceRegistry` 的资源发现、动态库加载和文件物化流程 #5167
sjtulxh创建于 11 天前
[feat] 完善 ACLRTC `ResourceRegistry` 的资源发现、动态库加载和文件物化流程 #5167
已合并
sjtulxh创建于 11 天前
sjtulxh成员
11 天前

描述

完善 ACLRTC ResourceRegistry 的资源发现、动态库加载和文件物化流程:

  • 显式加载仅接受合法的普通 SO 文件,不再支持传入目录扫描。
  • 在加载 SO、解析 OPP vendor 配置和物化资源文件前规范化路径,避免非规范化路径及软链接路径逃逸。
  • 单个 SO 加载、manifest 解析或资源冲突失败时输出告警并继续处理后续 SO;失败 SO 的暂存资源不会部分提交。
  • 补充关键 DFX 日志,并明确 lambda 捕获范围。
  • 更新 Load 接口注释。

关联的Issue

无。

测试

  • 更新 test_resource_registry.cpp,覆盖:
    • 显式目录拒绝、SO 路径规范化与不存在路径。
    • 单个 SO 失败后继续加载、失败 SO 暂存数据不提交。
    • OPP 路径规范化。
    • 物化路径规范化及软链接逃逸拦截。
  • 执行 ascendc_ut_aclrtc:89/89 用例通过。

文档更新

更新 resource_registry.hLoad 接口说明,明确显式加载不支持目录输入。

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 sjtulxh 的贡献)
Ssjtulxh成员
11 天前 创建了 pull request,commit bdac9c80
atomgit-bot
atomgit-bot
11 天前 评论:

变更摘要

本 PR 完善了 ACLRTC ResourceRegistry 的资源发现、动态库加载与文件物化流程:显式加载不再支持目录扫描、只接受普通 SO 文件;在加载 SO、解析 OPP vendor 配置及物化资源前统一规范化路径,拦截非规范化路径与软链接逃逸;单个 SO 加载或 manifest 解析失败时仅告警并跳过该 SO,其暂存资源不会部分提交,其余 SO 继续处理;同时补充 DFX 日志、明确 lambda 捕获范围,并更新 Load 接口注释与相关测试。

主要改动

  • 显式加载仅接受普通 SO 文件: ResolveExplicitDiscoveryPath 移除目录分支,目录输入直接返回 InvalidResourceDiscoverLibraries 显式模式不再做目录内 CollectLibraries 扫描,改为仅校验并注册单个规范化后的 SO。
  • 加载与发现前规范化路径: LoadLibrarydlopen 前通过 ResolveCanonicalPath 规范化 SO 路径并全程使用规范化路径记录日志;AutomaticSearchRoots 对 OPP root 与 vendors/config.ini 先规范化再解析 vendor 配置。
  • 物化路径规范化与软链接逃逸拦截: WriteMaterializedFiles 对输出 root 与父目录做规范化,并通过 IsPathWithin 校验父目录位于 root 之内,拒绝软链接重定向写入 root 之外,写入改用规范化路径。
  • 单 SO 失败继续加载且暂存不提交: LoadLibraries 改为按 SO 独立暂存(libraryStage),成功后经新增的 MergeStagedLibrary 合并资源(冲突或超限时跳过),失败仅告警并继续,全部失败时返回首个错误;Commit 中的 checkCategory lambda 明确 [this, &status] 捕获,HasCommitConflict 改为 const 成员函数。
  • 接口文档与测试更新: resource_registry.h 更新 Load 注释,明确显式加载不支持目录输入;test_resource_registry.cpp 新增/调整用例覆盖目录拒绝、SO 路径规范化、单 SO 失败继续加载、暂存不提交、OPP 路径规范化及物化软链接逃逸拦截。
likedislike
atomgit-bot
atomgit-bot
11 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
11 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
11 天前 评论:

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.
For more, you also can visit HICANN.


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
repo-cann/asc-devkit 诸葛洵, XuebinYang (2/2) 诸葛洵 (1/1)
tools/aclrtc YANXI_ZHAO, 诸葛洵, XuebinYang (3/2) YANXI_ZHAO (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
此处折叠了43条消息 查看更多
YANXI_ZHAO成员
11 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
11 天前 添加了label:approved
XuebinYang成员
11 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
11 天前 添加了label:lgtm
CANN-robotCANN-robot成员
11 天前 合入了pull request