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 for HW reset while RGB streaming #7647

Closed
wants to merge 8 commits into from

Conversation

nohayassin
Copy link
Contributor

track on DSO-15827
Fixed race between face detection thread and main thread of post processing filter that happens after HW reset

@ev-mp ev-mp requested a review from maloel October 25, 2020 15:17
Copy link
Collaborator

@maloel maloel left a comment

Choose a reason for hiding this comment

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

This seems like a workaround, not a fix -- let's talk about it?

@nohayassin
Copy link
Contributor Author

This seems like a workaround, not a fix -- let's talk about it?

check out the new fix with mutex

@dorodnic
Copy link
Contributor

Hi @nohayassin
I don't think mutex fix is correct - if subdevice is destructed, you may try to lock destroyed mutex...
Lets talk about it

common/model-views.cpp Outdated Show resolved Hide resolved
@ev-mp ev-mp changed the title DSO 15827 - bug fix of HW reset while RGB streaming Fix for HW reset while RGB streaming Oct 28, 2020
{
// joinable() only checks that the thread's alive -- but we don't want to join
// if we're here from within the worker thread itself!
if (std::this_thread::get_id() != _worker.get_id())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a preventive action ? The dtor ought not to be called from the spinoff thread anyway.
If it is - it can mark a circular dependency that we need to review.
Also the worker's thread's lifespan shall be encapsulated within the invoking object as it uses its resources, thus detach can be dangerous.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The dtor can get called from within the worker thread because of shared_ptr's reference counting:

device holds subdevice_model holds processing_block_model-list holds filter-ptr holds worker thread running in the bg
device goes away
~device calls ~subdevice_model calls ~processing_block_model calls ~filter-ptr

Here is where it gets interesting:

We don't want to destroy the filter until we're in a good place in the worker thread, because the worker thread is dependent on data that sits in there. So we have the worker thread lock the filter-ptr. But this means that, once the shared_ptr is released, the ~filter gets called and we're in the worker thread.

I'll hold off on the merge until you give your OK @ev-mp

Copy link
Collaborator

Choose a reason for hiding this comment

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

And, by the way --
I asked Noha to write a unit-test for this. Should be doable. She opened a ticket to track it.

@ev-mp
Copy link
Collaborator

ev-mp commented Nov 3, 2020

Continued in #7698

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants