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

Possible infinite wait in ThreadBase #274

Open
cochicde opened this issue Nov 14, 2024 · 0 comments
Open

Possible infinite wait in ThreadBase #274

cochicde opened this issue Nov 14, 2024 · 0 comments

Comments

@cochicde
Copy link
Contributor

The particular case occurs often during testing, when a device is created and then quickly destroyed.

The problem is that CThreadBase::start does not wait for the thread to actually start before returning. That means that if the caller calls stop (usually indirectly via diableHandler or something similar), the stop function will set the thread to alive = false, and join (wait indenitely).
Because the thread didn't actually start yet, the alive = false gets overwritten when the thread actually starts, so the caller waits for a thread to end which just actuallly started and gets stuck.

I think a semaphore will do the trick to coordinate this and make sure start waits for the thread before returning.

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

No branches or pull requests

1 participant