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

thread delegate must be destroyed before thread #3388

Merged
merged 1 commit into from
May 28, 2020
Merged

Conversation

iCollin
Copy link
Collaborator

@iCollin iCollin commented May 20, 2020

Fixes #3387

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

manually as described in issue

Summary

The thread delegate destructor writes on its thread_ pointer, so we must ensure that thread delegates are destroyed before threads.

CLA

@Jack-Byrne
Copy link
Collaborator

Searching for delegate() there are a lot of uses where set_delegate(NULL) is not called unlike the iap destructor example.

BluetoothDeviceScanner::~BluetoothDeviceScanner() {
  thread_->join();
  delete thread_->delegate();
  threads::DeleteThread(thread_);
}

Do these other uses need to call set_delegate(NULL) before calling delete?

@Jack-Byrne Jack-Byrne closed this May 21, 2020
@Jack-Byrne Jack-Byrne reopened this May 21, 2020
@iCollin
Copy link
Collaborator Author

iCollin commented May 21, 2020

Do these other uses need to call set_delegate(NULL) before calling delete?

They do not, Thread holds a raw pointer to the delegate and will not do anything with the delegate when its destructor is called.

@Jack-Byrne Jack-Byrne mentioned this pull request May 21, 2020
4 tasks
@iCollin
Copy link
Collaborator Author

iCollin commented May 21, 2020

Please notice that a new solution has been proposed in 30f5e86

@iCollin iCollin changed the title thread delegate does not modify parent thread in destructor thread delegate must be destroyed before thread May 21, 2020
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.

3 participants