Vlasis
Here is my suggestion. Do not create a process which you delete this causes problems with the factory system which is causing the segfault on shutdown. Use the PDECLARE_PROCESS macro instead to create a process for the life of the application.
So in place of your PProcess class you have
PDECLARE_PROCESS(asterisk,PProcess,"Asterisk","chan_h323",MAJOR_VERSION,MINO R_VERSION,BUILD_TYPE,BUILD_NUMBER) static asterisk chan_h323; // active for the life of the DLL void asterisk::Main() // implement the virtual function which is never called { }
I use this with PacPhone which has h323plus in an windows activeX DLL. It works fine.
so now the end Process can be simplified to:
void h323_end_process(void) { if (endPoint) { delete endPoint; endPoint = NULL; } if (logstream) { delete logstream; logstream = NULL; } }
This is my suggestion.
Simon
-----Original Message----- From: Vlasis Hatzistavrou (KTI) [mailto:vhatz@kinetix.gr] Sent: Saturday, 3 November 2007 1:12 AM To: Simon Horne Cc: H323plus Subject: Re: [h323plus] Using H323+ for Asterisk's chan_h323
Hello Simon,
I made quite some progress with chan_h323 and H323Plus.
The only problem that remains is that now Asterisk segfaults when the module unloads OR it is stopped (depending on the changes of the code, see below).
1) Initially, I traced the problem (first time user of gdb!!!) to when the function h323_end_process is called below, whenever the module is unloaded:
void h323_end_process(void) { if (endPoint) { endPoint->ClearAllCalls(); endPoint->RemoveListener(NULL); delete endPoint; endPoint = NULL; } if (localProcess) { delete localProcess; localProcess = NULL; /* close(_timerChangePipe[0]); */ /* close(_timerChangePipe[1]); */ } if (logstream) { PTrace::SetLevel(0); PTrace::SetStream(&cout); delete logstream; logstream = NULL; } }
I have found out that the segfault will happen after asterisk exits PTrace::SetStream , so I assume that "delete logstream" must be causing the problem. The above code would cause a segfault when chan_h323.so was unloaded.
2) gdb showed that logstream (a class concerning the logs of chan_h323) is in fact deleted during "PTrace::SetStream", so I tried to comment out the " delete logstream; logstream = NULL;" part of the code.
This seemed to do the trick partially, because then the module chan_h323.so would load and unload any number of times. However, asterisk would segfault when it was stopped, even if chan_h323.so was unloaded.
A useful fact is that asterisk seems to exit first by giving a signal SIG32, and AFTER that it segfaults:
*CLI> stop now [asterisk's command to shut down]
Program received signal SIG32, Real-time event 32. [Switching to Thread -1208759376 (LWP 17320)] 0x00bd77a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 (gdb) continue Continuing.
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1208756544 (LWP 17316)] 0x00322388 in PFactoryBase::FactoryMap::~FactoryMap () from /Downloads/h323p/ptlib_v1_12_0/lib/libpt_linux_x86_r.so.1.12.0 (gdb) where #0 0x00322388 in PFactoryBase::FactoryMap::~FactoryMap () from /Downloads/h323p/ptlib_v1_12_0/lib/libpt_linux_x86_r.so.1.12.0 #1 0x003223ce in __tcf_0 () from /Downloads/h323p/ptlib_v1_12_0/lib/libpt_linux_x86_r.so.1.12.0 #2 0x00c1a7a4 in __cxa_finalize () from /lib/tls/libc.so.6 #3 0x00225362 in __do_global_dtors_aux () from /Downloads/h323p/ptlib_v1_12_0/lib/libpt_linux_x86_r.so.1.12.0 #4 0x00322cb2 in _fini () from /Downloads/h323p/ptlib_v1_12_0/lib/libpt_linux_x86_r.so.1.12.0 #5 0x00be3907 in _dl_fini () from /lib/ld-linux.so.2 #6 0x00c1a527 in exit () from /lib/tls/libc.so.6 #7 0x0806c056 in quit_handler (num=Variable "num" is not available. ) at asterisk.c:1325 #8 0x0806c2c9 in handle_shutdown_now (fd=1, argc=2, argv=0xbff78b40) at asterisk.c:1504 #9 0x0808e1be in ast_cli_command (fd=1, s=0x9233068 "HG#\t¨<#\t") at cli.c:1979 #10 0x0806f718 in main (argc=2, argv=0xbff790c4) at asterisk.c:1395 #11 0x00c04de3 in __libc_start_main () from /lib/tls/libc.so.6 #12 0x08057ae1 in ?? ()
It seems that not deleting logstream explicitly leaves a lingering problem (where ???), but trying to delete it causes a segfault right then and there.
Note: As you can see in the code snippet above, I have just commented out the use of _timerChangePipe[], which was use in the destructor of MyProcess:
MyProcess::~MyProcess() { _timerChangePipe[0] = timerChangePipe[0]; _timerChangePipe[1] = timerChangePipe[1]; }
I have been trying to tackle this issue since quite a few days now with no serious progress, so any pointers as to where to look will be highly appreciated...
Best regards, Vlasis Hatzistavrou Kinetix Tele.com International Inc. 306 Victoria House, Victoria, Mahe, Seychelles Tel.: +302310556134 Fax: +302310556134 (ext. 0) GSM: +306977835653 e-mail: vhatz@kinetixtele.com http://www.kinetixtele.com
Postal address: Monastiriou 9 & Enotikon 54627 Thessaloniki Greece
Simon Horne wrote:
Around October last year timerChangePipe[] was replaced by process.breakBlock;
I suggest you troll through the changelog
http://openh323.cvs.sourceforge.net/openh323/pwlib/src/ptlib/unix/tlibthrd.c
xx?view=log
There has been quite a few changes around october last year.
I hope this helps and we can move ahead with h323plus support in Asterisk.
Simon
-----Original Message----- From: Vlasis Hatzistavrou (KTI) [mailto:vhatz@kinetix.gr] Sent: Monday, 29 October 2007 6:44 PM To: Simon Horne Cc: Plamen Petkov; H323plus Subject: Re: [h323plus] Using H323+ for Asterisk's chan_h323
Hello Simon,
Good news, chan_h323 is now able to use H323Plus!
:-)
There is only one small problem, it segfaults whenever the chan_h323.so module is unloaded or Asterisk is stopped (in which case the module is unloaded again). Otherwise everything is working as expected.
The problem for the segfault, however, is not related to H323. It seems that it is related with chan_h323's log stream which is a derivative class of PProcess. Apparently the PWLib/PTLib change had an effect on this and it segfaults whenever the logstream object is deleted.
I have the feeling that it is related to the timerChangePipe[] array which is missing in the newest PWLib versions.
I tried to find some documentation about this array but I couldn't find any. I'd be grateful if you could give me some pointers as to where to look for relevant information in order to wrap up chan_h323's transition to H323Plus.
Best regards, Vlasis Hatzistavrou Kinetix Tele.com International Inc. 306 Victoria House, Victoria, Mahe, Seychelles Tel.: +302310556134 Fax: +302310556134 (ext. 0) GSM: +306977835653 e-mail: vhatz@kinetixtele.com http://www.kinetixtele.com
Postal address: Monastiriou 9 & Enotikon 54627 Thessaloniki Greece
Simon Horne wrote:
Plamen
GnuGk has been test compiled with h323plus.
Your error looks strange as it seems to like the code 2 lines above 656 which is identical . I suggest you look at code to see if you have not accidently modified something particularily look at gk_const.h as well as RasTbl.cxx:658
I have fixed the warning message.
Simon
-----Original Message----- From: Plamen Petkov [mailto:plamen@bg-tel.com] Sent: Friday, 26 October 2007 2:57 AM To: Simon Horne Subject: Re: [h323plus] Using H323+ for Asterisk's chan_h323
Hello, I try to compile Gnugk with H323plus. That is the result:
RasTbl.cxx:658: error: no matching function for call to `H460_FeatureOID::Add(const char[2], H460_FeatureContent)' /root/openh323/include/h460/h4601.h:969: note: candidates are: H460_FeatureParameter& H460_FeatureOID::Add(const PString&, H460_FeatureContent&) RasTbl.cxx: In member function `void
CallTable::OnQosMonitoringReport(const
PString&, const endptr&, H4609_QosMonitoringReportData&)': RasTbl.cxx:2790: warning: unused variable 'addr' make[1]: *** [obj_linux_x86_r/RasTbl.o] Error 1
Regards: Plamen
----- Original Message ----- From: "Simon Horne" s.horne@packetizer.com To: vhatz@kinetix.gr; h323plus@lists.packetizer.com Sent: Thursday, October 25, 2007 6:44 PM Subject: Re: [h323plus] Using H323+ for Asterisk's chan_h323
Vlasis
I am not sure what chan_h323 looks like but there should be no need to have timerChangePipe I think this is a left over from very old code.
Have a look at simple in the CVS http://h323plus.cvs.sourceforge.net/h323plus/applications/simple/ to see how to define the PProcess
Simon
-----Original Message----- From: h323plus-bounces@lists.packetizer.com [mailto:h323plus-bounces@lists.packetizer.com]On Behalf Of Vlasis Hatzistavrou (KTI) Sent: Thursday, 25 October 2007 10:36 PM To: h323plus@lists.packetizer.com Subject: [h323plus] Using H323+ for Asterisk's chan_h323
Hello all,
I have been trying to compile chan_h323 with H323. It seems that I am almost done, although I get the following error:
g++ -DNDEBUG -I../../include -include ../../include/asterisk/autoconfig.h -fPIC -DP_USE_PRAGMA -D_REENTRANT -fno-exceptions -Wall -fPIC -DPIC -DNDEBUG -I/Downloads/h323p/ptlib_v1_12_0/include -DPTRACING -I/Downloads/h323p/h323plus/include -Os -pipe -felide-constructors -Wreorder -c ast_h323.cxx -o ast_h323.o ast_h323.cxx: In destructor `virtual MyProcess::~MyProcess()': ast_h323.cxx:194: error: `timerChangePipe' was not declared in this
scope
make[2]: *** [ast_h323.o] Error 1 make[1]: *** [h323/libchanh323.a] Error 2 make: *** [channels] Error 2
I went through the PWLib 1.12.0, and there is no occurrence of "timerChangePipe". In previous versions of PWLib "timerChangePipe" was used in quite a few places in the code.
I googled it, but I still don't know what it does.
If I comment it out in the destructor MyProcess::~MyProcess() it compiles, but the channel driver segfaults as soon as it is loaded...
-- Best regards, Vlasis Hatzistavrou.