OPAL: SIP Transports deletion, when STUN enabled
- From: "Jacek Stobnicki" <grippenek (at) go2.pl>
- Date: Sat, 28 Jan 2006 02:29:57 +0100
Hi again...
I'm testing new
release of OPAL intensively, as you can observe:>
Environment: Windows
XP, VS.NET 2003
There is a
problem with SIPEndPoint::TransportThreadMain method. When I set STUN, and
during exit delete OPALManager, program crashes (access violation reading
location 0xXXXXXXXX) at:
(sipep.cxx, v2.97,
line 664)
if (stunTransport) {
natTransportMutex.Wait(); ------>
here....
natTransports.Remove(transport);
natTransportMutex.Signal();
}
This code is after
main loop of transport thread, so it runs during deletion of
it.
Well, I've started
to debug the code, and after some time I have some
conclusions:
1) this problem
is connected with NAT binding which Damien implemented recently. Because
previous versions do not have this piece of code at all.
2) It seems that
there is some kind of race situation between thread that deletes
SIPEndpoint and transport threads.
I've observed that
when I'm deleting manager (and implicitly all classes connected to it),
sometimes:
A) this code
from TransportThreadMain is called before destructor of SIPEndpoint
(in MY machine very rare situation),
B) this
code runs AFTER destructor of endpoint (most of the
cases).
When A occurs -
all is clear, when B: the code use memory which is already free (becuase
class is already deleted) -> this is the cause of the crash and
access violation exception. I don't have neccesary knowledge of library
threading model to be able to correct this (but I'm understanding it
better and better....:).
When I disable STUN,
this piece of code is skipped, and program exits with no
problems.
In my opinion this
is very serious problem, but I must point that I didn't test this code on other
machines - maybe mine is not typical....
Regards:
Jacek
Stobnicki