project-chip / project-chip/connectedhomeip

CreateNewUDCClientState is not safe to call more than once in a row

Open
#8,564 5 comments 0 reactions 1 assignee View on GitHub

@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:

  1. CreateNewUDCClientState is called.
  2. Some time passes (e.g. thread lost timeslice)
  3. CreateNewUDCClientState is called again and returns the same pointer because the time passed was enough for the state we got to not be considered initialized anymore.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.