Skip to content

Commit

Permalink
Assert that controllers are inited and shut down with the Matter lock…
Browse files Browse the repository at this point in the history
… held. (#20178)

* Assert that controllers are inited and shut down with the Matter lock held.

We were not asserting this, and some consumers were not doing this,
leading to data races.

* Fix platform manager impls to correctly flag tasks as shut down.

* Undo the FreeRTOS changes.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jan 4, 2024
1 parent e304af8 commit 1286899
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include <lib/support/TimeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <messaging/ExchangeContext.h>
#include <platform/LockTracker.h>
#include <protocols/secure_channel/MessageCounterManager.h>
#include <setup_payload/QRCodeSetupPayloadParser.h>
#include <trace/trace.h>
Expand Down Expand Up @@ -105,6 +106,8 @@ DeviceController::DeviceController()

CHIP_ERROR DeviceController::Init(ControllerInitParams params)
{
assertChipStackLockedByCurrentThread();

VerifyOrReturnError(mState == State::NotInitialized, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(params.systemState != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

Expand Down Expand Up @@ -282,6 +285,8 @@ CHIP_ERROR DeviceController::InitControllerNOCChain(const ControllerInitParams &

void DeviceController::Shutdown()
{
assertChipStackLockedByCurrentThread();

VerifyOrReturn(mState != State::NotInitialized);

ChipLogDetail(Controller, "Shutting down the controller");
Expand Down

0 comments on commit 1286899

Please sign in to comment.