Tencent / Tencent/libpag

Data race: VideoReader::onReportPerformance / SequenceReader::reportPerformance read videoDecoder and decodingTime without a lock

Open
#3,733 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
5.8k
Forks
531
Avg merge
8d 55m
Merged PRs (30d)
17

Description

背景

由 PR #3709 的 review(@shlzxjp)提出,属于 #3709 范围之外的既有问题,单独跟踪。

问题

  • VideoReader::onReportPerformancesrc/rendering/sequences/VideoReader.cpp:94-107)在不持有 locker 的情况下解引用 videoDecoder(读取 videoDecoder->isHardwareBacked())。
  • 基类 SequenceReader::reportPerformancesrc/rendering/sequences/SequenceReader.cpp:33-38)也在无锁的情况下读写 decodingTime

竞争窗口

异步解码任务(tgfx TaskGroup 线程)可在 VideoReader::onMakeBufferdestroyVideoDecoder() / 重建 videoDecoder;与此同时,渲染线程在 flush 末尾经 RenderCache::recordPerformancesrc/rendering/caches/RenderCache.cpp:512)→ SequenceImageQueue::reportPerformanceSequenceReader::reportPerformanceVideoReader::onReportPerformance 走到同一路径,形成对 videoDecoderdecodingTime 的无锁并发读写。

与 #3709 的关系

#3709 为析构路径加锁,缓解了「析构 vs onMakeBuffer」一侧的风险,但上述 reportPerformance 读写竞争与析构锁无关,仍然存在。

建议

评估在 onReportPerformance / reportPerformance 读写 videoDecoderdecodingTime 时补充与 onMakeBuffer 一致的加锁保护,或改用原子/快照方式规避竞争。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read VideoReader.cpp at onReportPerformance and onMakeBuffer, then trace SequenceReader.cpp, RenderCache.cpp, and SequenceImageQueue::reportPerformance. Compare the existing locking around decoder changes with the performance-reporting reads and writes. Done means videoDecoder and decodingTime are accessed safely across these threads, with the relevant race no longer reproducible.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.