diff --git a/src/platform/tests/TestDnssd.cpp b/src/platform/tests/TestDnssd.cpp index 3006b00f0155e9..1102e1d3c5c665 100644 --- a/src/platform/tests/TestDnssd.cpp +++ b/src/platform/tests/TestDnssd.cpp @@ -83,6 +83,9 @@ static void HandleResolve(void * context, DnssdService * result, const chip::Spa if (ctx->mBrowsedServicesCount == ++ctx->mResolvedServicesCount) { chip::DeviceLayer::SystemLayer().CancelTimer(Timeout, context); + // StopEventLoopTask needs to be called from inside the Matter event loop, but we + // might not be in there right now; instead we might be on some other thread, but + // holding the Matter lock. chip::DeviceLayer::SystemLayer().ScheduleLambda([]() { // After last service is resolved, stop the event loop, // so the test case can gracefully exit.