Make sure that Server init and shutdown happen with the stack lock held. (#25041)
diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp
index c41f5c3..c1d6d25 100644
--- a/src/app/server/Server.cpp
+++ b/src/app/server/Server.cpp
@@ -43,6 +43,7 @@
#include <platform/DeviceControlServer.h>
#include <platform/DeviceInfoProvider.h>
#include <platform/KeyValueStoreManager.h>
+#include <platform/LockTracker.h>
#include <protocols/secure_channel/CASEServer.h>
#include <protocols/secure_channel/MessageCounterManager.h>
#include <setup_payload/SetupPayload.h>
@@ -105,6 +106,7 @@
CHIP_ERROR Server::Init(const ServerInitParams & initParams)
{
ChipLogProgress(AppServer, "Server initializing...");
+ assertChipStackLockedByCurrentThread();
CASESessionManagerConfig caseSessionManagerConfig;
DeviceLayer::DeviceInfoProvider * deviceInfoprovider = nullptr;
@@ -461,6 +463,7 @@
void Server::Shutdown()
{
+ assertChipStackLockedByCurrentThread();
PlatformMgr().RemoveEventHandler(OnPlatformEventWrapper, 0);
mCASEServer.Shutdown();
mCASESessionManager.Shutdown();