Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 624375fd authored by Shuzhen Wang's avatar Shuzhen Wang Committed by John Reck
Browse files

BQ: Fix deadlock introduced by onFrameDequeued

BufferQueueCore::mMutex should never be locked when calling
consumerListener's callbacks.

The reason is that the consumerListener callback could in turn
acquire BufferQueueCore::mMutex, resulting in deadlock.

The deadlock stack trace for onFrameDequeued is:

- BufferQueueProduer::dequeueBuffer acquires Core::mMutex
  - ProxyConsumerListener::onFrameDequeued::onFrameDequeued
    promotes a ConsumerListener wp to sp
  - The sp becomes the last reference to the ConsumerListener object,
    when onFrameDequeued() goes out of scope, ~ConsumerListener is
    called
    - BufferQueueConsumer::disconnect is called as part of
      ~ConsumerListener(), and disconnect needs to acquire Core::mMutex

The same issue applies to onFrameCancelled and onFrameDetached.

Test: atest BufferQueueThreading::TestProducerDequeueConsumerDestroy
Bug: 270004534
Change-Id: I22fdc637ccc937594656d6f5bc1ee9b7c506490a
parent 71233d8c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment