project-chip / project-chip/connectedhomeip
CreateNewUDCClientState is not safe to call more than once in a row
Open
@chrisdecenzo is already working on this.
Since Aug 11, 2021.
V1.X
- Dominant language
- C++
- Stars
- 9k
- Forks
- 2.5k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 314
Description
Problem
Consider the following order of events:
CreateNewUDCClientStateis called.- Some time passes (e.g. thread lost timeslice)
CreateNewUDCClientStateis called again and returns the same pointer because the time passed was enough for the state we got to not be considered initialized anymore.- Consumer now tries to do something with the state from step 1.
This never happens in our code right now (as long as all access to the UDC client states is on a single thread) because we never store the pointers CreateNewUDCClientState returns across another call to CreateNewUDCClientState. But this seems pretty fragile.
Proposed Solution
Figure out a safer API.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.