Skip to content

fix(vdec): serialize capture ownership during flush - #39

Open
mingjie-wu-spacemit wants to merge 1 commit into
mainfrom
fix/vdec-capture-ownership-flush
Open

mingjie-wu-spacemit wants to merge 1 commit into
mainfrom
fix/vdec-capture-ownership-flush

Conversation

@mingjie-wu-spacemit

Copy link
Copy Markdown
Collaborator

Summary

  • Pause new capture dequeue requests while a channel flush is in progress.
  • Wait for an in-flight dequeue to finish before flushing the capture queue.
  • Serialize capture ownership updates and recycle QBUF operations without holding the ownership lock across the existing 100 ms waits.
  • Drain the GetFrame depth queue and re-queue only buffers that were still decoder-owned before the flush.
  • Wake paused output work during channel shutdown.

Validation

  • scripts/lint/lint_cpp.sh mpi/vdec
  • Clean Release CMake build

@spacemit-robot-ci

spacemit-robot-ci Bot commented Aug 7, 2026

Copy link
Copy Markdown

Robot CI AI Review

结论:发现 1 个需要处理的问题。

发现:

  1. [严重] mpi/vdec/vdec.c:1494-1516 flush 失败时缓冲区所有权状态被错误清空且未恢复
    代码在调用 pChn->stOps.flush() 之前,无条件将所有 buffer 的 bInDecoder 置为 MPP_FALSE(同时记录 wasInDecoder/hadDecoderRef 用于之后重新入队)。但重新入队/恢复状态的循环被包在 if (ret == MPP_OK) 内,只有 flush 成功时才会执行。如果 pChn->stOps.flush() 返回失败,原本仍被 decoder 持有(wasInDecoder[i] == TRUE)的 buffer 会被永久标记为 bInDecoder = FALSE,但既没有真正被 dequeue,也没有被重新 queue 回 decoder,导致缓冲区所有权状态与实际不一致。后续 recycle/output 线程可能据此误判该 buffer 已可回收/复用,产生 use-after-free 或与 decoder 侧状态冲突的风险。
    建议:在 ret != MPP_OK 分支中也要处理这些 buffer,例如恢复其 bInDecoder 为原值,或者明确记录/上报错误状态,避免所有权信息与硬件/驱动实际状态脱节。

备注:worker-cache review 失败,已回退 baseline review:worker-cache review failed: snode5: busy; hp-probook: sync worker helper failed: ssh: connect to host 10.0.91.193 port 22: No route to host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant