Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out-of order resources deallocation #7698

Merged
merged 5 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion common/post-processing-worker-filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ class post_processing_worker_filter : public post_processing_filter
{
}
~post_processing_worker_filter()
{
release_background_worker();
ev-mp marked this conversation as resolved.
Show resolved Hide resolved
}

// Worker thread uses resources of classes that inherit from this class (e.g openvino_face_detection),
// so it should be released from inherited classes.
// This should be called from dtor of inherited classes!
void release_background_worker()
{
_alive = false;
if( _worker.joinable() )
if (_worker.joinable())
_worker.join();
}

Expand Down
6 changes: 6 additions & 0 deletions tools/realsense-viewer/openvino-face-detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ class openvino_face_detection : public post_processing_worker_filter
{
}

~openvino_face_detection()
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest the following:
"Complete background worker to ensure it releases the instance's resources in controlled manner"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it

// The worker filter will do this itself, but we must manually do it if we want to avoid a crash
// by access to our data (gone by the time we get to the parent dtor) by the worker thread!
release_background_worker();
}
public:
void start( rs2::subdevice_model & model ) override
{
Expand Down