Address concurrency failures between calls to decrypt and periodic timer
[ http://go/wvgerrit/50341 ] The shared_ptr implementation was taken from a google3 implementation. Updates to the reference counter needed to be atomic and were platform dependent in the original code. These were not carried over to this codebase. Race conditions between calls to decrypt and the periodic timer, led to incorrect reference count values. CdmSession objects were then destructed while references to them still existed. Segfaults occurred when they were referenced. Bug: 79431096 Test: WV unit/integration tests, GTS GtsMediaTestCases tests and 24 hours of continuous Netflix playback. Change-Id: I6008ddba869efcc58972e5ea8644a204f91410ab
This commit is contained in:
@@ -12,9 +12,17 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "lock.h"
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
|
namespace wvcdm {
|
||||||
|
|
||||||
|
extern Lock shared_ptr_ref_count_lock_;
|
||||||
|
|
||||||
|
} // namespace wvcdm
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool Barrier_AtomicIncrement(volatile uint32_t* ptr, uint32_t value) {
|
bool Barrier_AtomicIncrement(volatile uint32_t* ptr, uint32_t value) {
|
||||||
*ptr += value;
|
*ptr += value;
|
||||||
return *ptr;
|
return *ptr;
|
||||||
@@ -25,10 +33,12 @@ bool NoBarrier_AtomicIncrement(volatile uint32_t* ptr, uint32_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool RefCountDec(volatile uint32_t *ptr) {
|
inline bool RefCountDec(volatile uint32_t *ptr) {
|
||||||
|
wvcdm::AutoLock auto_lock(wvcdm::shared_ptr_ref_count_lock_);
|
||||||
return Barrier_AtomicIncrement(ptr, -1) != 0;
|
return Barrier_AtomicIncrement(ptr, -1) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RefCountInc(volatile uint32_t *ptr) {
|
inline void RefCountInc(volatile uint32_t *ptr) {
|
||||||
|
wvcdm::AutoLock auto_lock(wvcdm::shared_ptr_ref_count_lock_);
|
||||||
NoBarrier_AtomicIncrement(ptr, 1);
|
NoBarrier_AtomicIncrement(ptr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ const size_t kUsageReportsPerRequest = 1;
|
|||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
|
|
||||||
|
Lock shared_ptr_ref_count_lock_;
|
||||||
|
|
||||||
class UsagePropertySet : public CdmClientPropertySet {
|
class UsagePropertySet : public CdmClientPropertySet {
|
||||||
public:
|
public:
|
||||||
UsagePropertySet() {}
|
UsagePropertySet() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user