mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-10 11:30:04 +08:00
[meta/buffer]: Fix usage after service is destoyed
When C++ global destructor is called MppBufferService and MppMetaService maybe be called before other destructors which may call mpp_buffer_put and mpp_meta_put. So we mark finished flag after ~MppBufferService and ~MppMetaService is call and so not free corresponding data again. This case usually happens when user call exit() directly. Change-Id: I997c49b095e443b061fca230587b6216f710d31c Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
@@ -75,6 +75,7 @@ private:
|
|||||||
RK_U32 group_id;
|
RK_U32 group_id;
|
||||||
RK_U32 group_count;
|
RK_U32 group_count;
|
||||||
RK_U32 finalizing;
|
RK_U32 finalizing;
|
||||||
|
RK_U32 finished;
|
||||||
|
|
||||||
// misc group for internal / externl buffer with different type
|
// misc group for internal / externl buffer with different type
|
||||||
MppBufferGroupImpl *misc[MPP_BUFFER_MODE_BUTT][MPP_BUFFER_TYPE_BUTT];
|
MppBufferGroupImpl *misc[MPP_BUFFER_MODE_BUTT][MPP_BUFFER_TYPE_BUTT];
|
||||||
@@ -604,6 +605,7 @@ MppBufferService::MppBufferService()
|
|||||||
: group_id(0),
|
: group_id(0),
|
||||||
group_count(0),
|
group_count(0),
|
||||||
finalizing(0),
|
finalizing(0),
|
||||||
|
finished(0),
|
||||||
misc_count(0)
|
misc_count(0)
|
||||||
{
|
{
|
||||||
RK_S32 i, j;
|
RK_S32 i, j;
|
||||||
@@ -655,6 +657,7 @@ MppBufferService::~MppBufferService()
|
|||||||
deinit_buffer_no_lock(pos, __FUNCTION__);
|
deinit_buffer_no_lock(pos, __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finished = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RK_U32 MppBufferService::get_group_id()
|
RK_U32 MppBufferService::get_group_id()
|
||||||
@@ -745,6 +748,9 @@ void MppBufferService::set_misc(MppBufferMode mode, MppBufferType type, MppBuffe
|
|||||||
|
|
||||||
void MppBufferService::put_group(MppBufferGroupImpl *p)
|
void MppBufferService::put_group(MppBufferGroupImpl *p)
|
||||||
{
|
{
|
||||||
|
if (finished)
|
||||||
|
return ;
|
||||||
|
|
||||||
buffer_group_add_log(p, NULL, GRP_RELEASE, __FUNCTION__);
|
buffer_group_add_log(p, NULL, GRP_RELEASE, __FUNCTION__);
|
||||||
|
|
||||||
// remove unused list
|
// remove unused list
|
||||||
|
@@ -69,6 +69,7 @@ private:
|
|||||||
RK_U32 meta_id;
|
RK_U32 meta_id;
|
||||||
RK_U32 meta_count;
|
RK_U32 meta_count;
|
||||||
RK_U32 node_count;
|
RK_U32 node_count;
|
||||||
|
RK_U32 finished;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static MppMetaService *get_instance() {
|
static MppMetaService *get_instance() {
|
||||||
@@ -101,7 +102,8 @@ public:
|
|||||||
MppMetaService::MppMetaService()
|
MppMetaService::MppMetaService()
|
||||||
: meta_id(0),
|
: meta_id(0),
|
||||||
meta_count(0),
|
meta_count(0),
|
||||||
node_count(0)
|
node_count(0),
|
||||||
|
finished(0)
|
||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&mlist_meta);
|
INIT_LIST_HEAD(&mlist_meta);
|
||||||
INIT_LIST_HEAD(&mlist_node);
|
INIT_LIST_HEAD(&mlist_node);
|
||||||
@@ -128,6 +130,7 @@ MppMetaService::~MppMetaService()
|
|||||||
put_node(pos);
|
put_node(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finished = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RK_S32 MppMetaService::get_index_of_key(MppMetaKey key, MppMetaType type)
|
RK_S32 MppMetaService::get_index_of_key(MppMetaKey key, MppMetaType type)
|
||||||
@@ -166,6 +169,9 @@ MppMetaImpl *MppMetaService::get_meta(const char *tag, const char *caller)
|
|||||||
|
|
||||||
void MppMetaService::put_meta(MppMetaImpl *meta)
|
void MppMetaService::put_meta(MppMetaImpl *meta)
|
||||||
{
|
{
|
||||||
|
if (finished)
|
||||||
|
return ;
|
||||||
|
|
||||||
mpp_assert(meta->ref_count);
|
mpp_assert(meta->ref_count);
|
||||||
if (meta->ref_count)
|
if (meta->ref_count)
|
||||||
meta->ref_count--;
|
meta->ref_count--;
|
||||||
|
Reference in New Issue
Block a user