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

missing locking #6251

Closed
mspang opened this issue Apr 23, 2021 · 4 comments
Closed

missing locking #6251

mspang opened this issue Apr 23, 2021 · 4 comments
Labels
stale Stale issue or PR V1.X

Comments

@mspang
Copy link
Contributor

mspang commented Apr 23, 2021

CHIP device layer starts an IO thread to be able to respond to network activity, timers, etc. Once this task starts, calls to CHIP on any other thread must be guarded by LockChipStack/UnlockChipStack to avoid data races.

This locking is missing in many places where it is required, and must be added.

A simple approach would be to have any other threads queue their tasks via ScheduleWork() as this will invoke the task on the IO thread with the stack lock held.

See #6155, #6207 for examples of the damage we're seeing that results from improper synchronization.

@erjiaqing
Copy link
Contributor

I would also suggest to discuss the return value of some APIs here.

I also agree that most APIs can use ScheduleWork() -- especially those just send messages, however, this also means that the code becomes asynchronous for those APIs, this may change the way of error handling code.

@andy31415
Copy link
Contributor

In python I added a 'ScheduleWorkAndWait' for the locking aspect

@stale
Copy link

stale bot commented Jul 25, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issue or PR label Jul 25, 2022
@stale
Copy link

stale bot commented Oct 18, 2022

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issue or PR V1.X
Projects
None yet
Development

No branches or pull requests

4 participants