Open agners opened 6 days ago
Thanks, @agners.
Based on my analysis, this appears to be a platform UDP issue and not related to SRP client itself. I assume OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
is enabled and used, which delegates the handling of UDP sockets to the underlying platform (POSIX in this case).
The assertion is happening in Udp::Open()
where the socket seems to already be open:
Error Udp::Open(SocketHandle &aSocket, ReceiveHandler aHandler, void *aContext)
{
Error error = kErrorNone;
OT_ASSERT(!IsOpen(aSocket));
aSocket.Clear();
aSocket.mHandler = aHandler;
aSocket.mContext = aContext;
...
The Srp::Client::ProcessAutoStart()
method will always stop the client (which in turn closes the UDP socket) before restarting it again:
if (IsRunning())
{
VerifyOrExit((GetServerAddress() != serverSockAddr) || shouldRestart);
Stop(kRequesterAuto, kResetRetryInterval);
}
...
IgnoreError(Start(serverSockAddr, kRequesterAuto));
The Udp::Close()
method can fail only when CONFIG_PLATFORM_UDP_ENABLE
is used and the platform provided otPlatUdpClose()
fails:
Error Udp::Close(SocketHandle &aSocket)
{
Error error = kErrorNone;
VerifyOrExit(IsOpen(aSocket));
#if OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
error = otPlatUdpClose(&aSocket);
#endif
SuccessOrExit(error);
RemoveSocket(aSocket);
aSocket.GetSockName().Clear();
aSocket.GetPeerName().Clear();
exit:
return error;
}
My suggestion is to investigate the otPlatUdpClose()
implementation (whether there are any additional changes in it) and if/how it may fail.
Describe the bug A clear and concise description of what the bug is.
I've encountered a crash using a relatively recent commit ff7227ea9a2dc0e50f92ab93bd5c9a29e82fe793. It coincided with the shutdown of another OTBR on the same network (this might be by chance, but the timing is very suspicious). This has been observed with the Home Assistant OpenThread Border Router add-on 2.11.0.
To Reproduce Information to reproduce the behavior, including:
Expected behavior A clear and concise description of what you expected to happen.
Console/log output If applicable, add console/log output to help explain your problem.
Additional context Add any other context about the problem here.