sipsorcery
sipsorcery copied to clipboard
ObjectDisposedException on 6.0.12
After upgrading to 6.0.12, an exception started getting thrown, (possibly only) in case the call is not picked:
Failed: Busy here, Status code: 486
System.ObjectDisposedException: The semaphore has been disposed.
at System.Threading.SemaphoreSlim.CheckDispose()
at System.Threading.SemaphoreSlim.Release(Int32 releaseCount)
at System.Threading.SemaphoreSlim.Release()
at SIPSorcery.SIP.App.SIPUserAgent.CallEnded(String callId)
at SIPSorcery.SIP.App.SIPUserAgent.ClientCallAnsweredHandler(ISIPClientUserAgent uac, SIPResponse sipResponse)
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
Since this exception is thrown from a SIPSorcery-specific thread and therefore unhandled, it can crash the whole application.
We have been calling SIPUserAgent.Dispose manually for a while and this issue did not occur in older versions. It might not be necessary to call it for newer versions, but the semaphore should definitely not be accessed from an already disposed SIPUserAgent in such a thread.