Win32 Ekiga stable crashes on exit under Win Vista with service pack 2. The gdb backtrace shows
Program received signal SIGSEGV, Segmentation fault.
[Switching to thread 3916.0xf00]
0x00000000 in ?? ()
....
Thread 3 (thread 3916.0xf00):
#0 0x00000000 in ?? ()
#1 0x0080af85 in PWaitAndSignal::PWaitAndSignal (this=0xa70f5c0,
sem=@0xb0f0b8, wait=true)
at /home/mrickma/src/ekiga-stable/ekiga_build-3.2.5/ptlib-2.6.4/include/ptlib/psync.h:103
#2 0x00776b00 in PIPSocket::Address::AsString (this=0x9456598,
bracketIPv6=true) at ptlib/common/sockets.cxx:1894
#3 0x00501ee9 in OpalTransportAddress::OpalTransportAddress (this=0xa70f990,
addr=@0x9456598, port=5060, proto=0xa68f23 "udp$")
at /home/mrickma/src/ekiga-stable/ekiga_build-3.2.5/opal-3.6.4/src/opal/transports.cxx:98
#4 0x00502045 in OpalTransportIP::GetRemoteAddress (this=0x9456448)
at /home/mrickma/src/ekiga-stable/ekiga_build-3.2.5/opal-3.6.4/src/opal/transports.cxx:955
#5 0x0051f328 in SIPEndPoint::NATBindingRefresh (this=0x94f1ec0)
at /home/mrickma/src/ekiga-stable/ekiga_build-3.2.5/opal-3.6.4/src/sip/sipep.cxx:198
#6 0x00910b7c in SIPEndPoint::NATBindingRefresh_PNotifier::Call (
this=0x94ee0e8, note=@0x94f22d8, extra=1)
at /home/mrickma/src/ekiga-stable/ekiga_build-3.2.5/opal-3.6.4/include/sip/sipep.h:808
#7 0x00960473 in PNotifier::operator() (this=0x94f22e8, notifier=@0x94f22d8,
extra=1)
at /home/mrickma/src/ekiga-stable/ekiga_build-3.2.5/ptlib-2.6.4/include/ptlib/notifier.h:125
#8 0x0074779e in PTimer::OnTimeout (this=0x94f22d8)
at ptlib/common/osutils.cxx:797
#9 0x00747711 in PTimer::Process (this=0x94f22d8, delta=@0xa70fcc8,
minTimeLeft=@0xa70fcb8) at ptlib/common/osutils.cxx:831
#10 0x00748e3f in PTimerList::Process (this=0xb0c1e8)
at ptlib/common/osutils.cxx:958
#11 0x00754d5e in PProcess::HouseKeepingThread::Main (this=0x94e2d80)
at ptlib/msos/win32.cxx:1112
#12 0x00756cd6 in PThread::MainFunction (threadPtr=0x94e2d80)
at ptlib/msos/win32.cxx:707
#13 0x772f2599 in wcstombs () from C:\Windows\system32\msvcrt.dll
#14 0x772f26b3 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#15 0x760ed0e9 in KERNEL32!AcquireSRWLockExclusive ()
from C:\Windows\system32\kernel32.dll
#16 0x777919bb in ntdll!RtlInitializeNtUserPfn ()
from C:\Windows\system32\ntdll.dll
#17 0x7779198e in ntdll!RtlInitializeNtUserPfn ()
from C:\Windows\system32\ntdll.dll
#18 0x00000000 in ?? ()
The problem lies in " static PCriticalSection x; ". To clarify what happens I disassembled socket.o. This is the snipped showing the constructor
PWaitAndSignal::PWaitAndSignal(PSync const&, bool) :
00006940 push ebp
00006941 mov ebp, esp
00006943 sub esp, 8
00006946 mov eax, [ebp+arg_8]
00006949 mov [ebp+var_4], al
0000694C mov edx, [ebp+arg_0]
0000694F mov eax, [ebp+arg_4]
00006952
00006952 mov [edx], eax
00006954 cmp [ebp+var_4], 0
00006958 jz short locret_6974
0000695A mov eax, [ebp+arg_0]
0000695D mov eax, [eax]
0000695F mov eax, [eax]
00006961 add eax, 28h ; '('
00006964 mov edx, [eax]
00006966 mov eax, [ebp+arg_0]
00006969 mov eax, [eax]
0000696B sub esp, 0Ch
0000696E push eax
0000696F call edx
00006971 add esp, 10h
00006974
00006974 locret_6974:
00006974 leave
00006975 retn
As ckecked with gdb, through the " call edx " the ::EnterCriticalSection(&criticalSection); of include/ptlib/msos/ptlib/ptlib.inl is reached during normal oparation, i.e. before Ekiga exits. On exit however, the " call edx " produces above error indicating that PINLINE void PCriticalSection::Wait(), which is not inline but lies somewhere else in memory has been cleaned up.
This can be solved by using a dynamic PCriticalSection object at sockets.cxx:1894 ommiting the keyword static. My ptlib_critsec.diff limits that to Mingw and Cygwin as it may be really a compiler issue mixing up dynamic (through PMutex) and static allocations of the PCriticalSection functions.
Our next problem, stuck on exit under Vista, becomes accessible now.
Regards
Michael
use dynamic PCriticalSection in sockets.cxx for Mingw and Cygwin