[libspacemit_ep.so.2][SIGSEGV] SpaceMIT EP 编译 ONNX Clip 算子时 OnnxTensorData::GetBufferRaw() 空指针崩溃(depth_anything-3 的输入为5维,当前架构是否支持5维输入)

【问题概述】
应用 com.example.k3_depth_anything 在加载 ONNX 模型并执行首次 Warmup/Session.Run 时,SpaceMIT ONNX Runtime EP 内部 WorkerThread 发生原生崩溃。崩溃信号为 SIGSEGV(SEGV_MAPERR)@0x0000000000000078,初步判断为空指针解引用。崩溃发生在 libspacemit_ep.so.2 编译 ONNX Clip 算子阶段,不在应用 JS/ArkTS 层。

【环境信息】
设备:Spacemit K3-Pico
系统:OpenHarmony 6.1.0.35
CpuAbi:riscv64
应用:com.example.k3_depth_anything 1.0.0,ReleaseType: debug
进程:Pid 16288,Uid 20010057
崩溃时间:2026-11-04 15:32:17.575
崩溃线程:Tid 25364,Name: WorkerThread
相关库:
/system/lib64/libspacemit_ep.so.2
/system/lib64/libonnxruntime.so.1
/data/storage/el1/bundle/libs/riscv64/libentry.so

【模型与触发场景】
模型路径:/data/models/depthv3/da3_small_1view.fp16.onnx
模型大小:62447987 字节
输入:images,形状 1x1x3x280x504,类型 1(FLOAT)
输出:depth / depth_conf / extrinsics / intrinsics
应用日志显示:

  • SpaceMIT EP 已启用
  • 使用 CPU 推理
  • 开始预热,空张量 504 x 280
  • Session.Run 开始:504 x 280,元素 423360
    随后约 118ms 后发生 SIGSEGV。

【崩溃栈】
Reason: Signal:SIGSEGV(SEGV_MAPERR)@0x0000000000000078 probably caused by NULL pointer dereference
Fault thread: Tid:25364, Name:WorkerThread
#00 pc 00000000002f2e3e /system/lib64/libspacemit_ep.so.2(onnxruntime::spacemit::OnnxTensorData::GetBufferRaw()+8)
#01 pc 0000000000369718 /system/lib64/libspacemit_ep.so.2(onnxruntime::spacemit::SpineUnaryOperator::Compile(onnxruntime::spacemit::SpineGraphExecutor&)+1444)
#02 pc 000000000036b4be /system/lib64/libspacemit_ep.so.2(onnxruntime::spacemit::RegisterSpineOperatorForClip()::$_0::__invoke(onnxruntime::spacemit::SpineGraphExecutor&, onnxruntime::spacemit::SpineNode&)+126)
#03 pc 00000000002f47f8 /system/lib64/libspacemit_ep.so.2(onnxruntime::spacemit::SpineOperatorManager::CreateOperator(onnxruntime::spacemit::SpineGraphExecutor&, onnxruntime::spacemit::SpineNode&)+98)
#04 pc 00000000003969a4 /system/lib64/libspacemit_ep.so.2(onnxruntime::spacemit::SpineGraphExecutor::AddKernels()+78)
#05 pc 00000000003b29f6 /system/lib64/libspacemit_ep.so.2

【初步分析】
崩溃点为 OnnxTensorData::GetBufferRaw()+8,访问地址 0x78,属于典型空指针/空对象字段偏移访问。调用链显示 SpaceMIT EP 正在为 Clip 节点注册/创建算子,SpineUnaryOperator::Compile 在编译 Clip 时调用了 GetBufferRaw(),但对应 OnnxTensorData 对象为空。怀疑 EP 对 ONNX Clip 节点的可选输入 min/max、常量输入或 opset 差异处理不完整,未做空指针判断;不支持时也未回退 CPU EP,而是直接 SIGSEGV。

【复现步骤】

  1. 在 Spacemit K3-Pico / OpenHarmony 6.1.0.35 上安装 com.example.k3_depth_anything。
  2. 使用 /data/models/depthv3/da3_small_1view.fp16.onnx。
  3. 启用 SpaceMIT EP,执行 DepthEngine::LoadModel() 后调用 Warmup()/首次 Session.Run。
  4. 进程在 SpaceMIT EP 编译 Clip 算子时崩溃。

【已做的排查/请厂商确认】

  1. 设备可用内存约 13.5GB,进程 RSS 约 355MB,排除 OOM。
  2. 主线程处于 epoll_wait,崩溃线程为 EP WorkerThread,排除主线程 ANR。
  3. 请确认 libspacemit_ep.so.2 与 libonnxruntime.so.1 版本是否匹配。
  4. 请确认该 EP 对 Clip opset 11+ 的可选 min/max 输入、initializer 形式、FLOAT/FP16 混合模型是否支持。
  5. 如需,我方可提供最小复现工程、模型 Clip 节点 dump,以及禁用 SpaceMIT EP 后纯 CPU EP 的对比日志。

log.zip (440.3 KB)