Dear Holger,<br><br>Three points here. More so related to the language C instead of asterisk:-<br><ol><li>free() does *NOT* set the ptr to NULL. It just marks the allocated memory as unused. The ptr will still keep pointing to the same address. Its the programmer&#39;s responsibility to ensure that ptr is not used again in this state.</li>
<li>From the manual page of free (defined in stdlib.h),:-<br><br>&quot;&quot;free()  frees the memory space pointed to by ptr, which must have been returned by a<br>       previous call to malloc(), calloc() or realloc().  Otherwise, or  if  free(ptr)  has<br>
       already  been  called before, undefined behaviour occurs.  If ptr is NULL, no opera-<br>       tion is performed. &quot;&quot;<br><br>So, if ptr is NULL, you do not need to perform a check anyways, because free() will handle it cleanly.<br>
<br></li><li>Thirdly, by putting some simple debug logs just before free() [Just print the address being free&#39;d], you can determine if or not, you are calling free() on the same ptr twice.</li></ol><br>Btw, what (and why) design or architectural differences are you making from app_conference ?<br>
<br><br>Prince Singh<br>Drishti-Soft Solutions Pvt. Ltd., India<br><a href="http://www.drishti-soft.com">http://www.drishti-soft.com</a><br><a href="http://blog.drishti-soft.com">http://blog.drishti-soft.com</a><br><br><div class="gmail_quote">
On Fri, May 22, 2009 at 1:43 PM, Holger Wirtz <span dir="ltr">&lt;<a href="mailto:wirtz@dfn.de">wirtz@dfn.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
<br>
I am writing on an own conference bridge which should be used for a real<br>
radio simulation for the open source flight simulation FlightGear<br>
(current Asterisk module code can be found at<br>
<a href="https://sourceforge.net/projects/appfgcom/" target="_blank">https://sourceforge.net/projects/appfgcom/</a>). The basic idea behind is<br>
taken from app_conference: Every caller has its own member thread where<br>
frames are put onto a member-in-queue. A conference thread than mixes<br>
the frames from every member-in-queue together in every meber-out-queues<br>
(currently not based on their virtual distance). From<br>
themember-out-queue the meber-threads picks the frames and sends them to<br>
the channel and frees them.<br>
<br>
Because this is my first development for Asterisk it seems that have<br>
some problems of understanding some basic technology. At the current<br>
state the conference bridge works - I can place several calls and mix<br>
them in slinear together.<br>
<br>
But I get crashes like the following when running two or three calls for<br>
some time:<br>
<br>
--- cut here ---<br>
...<br>
    -- Hungup &#39;IAX2/193.174.1.6:4569-11496&#39;<br>
*** glibc detected *** asterisk: double free or corruption (out):<br>
0xb5b75778 ***<br>
======= Backtrace: =========<br>
/lib/libc.so.6[0xb7d9b215]<br>
/lib/libc.so.6(cfree+0x9c)[0xb7d9caec]<br>
asterisk(ast_frame_free+0x3d)[0x809c39d]<br>
/usr/lib/asterisk/modules/app_fgcom.so(member_exec+0x3e4)[0xb66dac54]<br>
/usr/lib/asterisk/modules/app_fgcom.so[0xb66da049]<br>
asterisk(pbx_exec+0x6b)[0x80b8c7b]<br>
asterisk[0x80b9992]<br>
/usr/lib/asterisk/modules/app_macro.so[0xb649dd50]<br>
asterisk(pbx_exec+0x6b)[0x80b8c7b]<br>
asterisk[0x80b9992]<br>
asterisk[0x80bab15]<br>
asterisk[0x80bb5ae]<br>
asterisk[0x80e3ac7]<br>
/lib/libpthread.so.0[0xb7ee5f50]<br>
/lib/libc.so.6(clone+0x5e)[0xb7dfd69e]<br>
...<br>
--- cut here ---<br>
<br>
Sometimes I geta simple &quot;Segmentation fault&quot;...<br>
<br>
I know what this means - but I don&#39;t know why this happens... Before<br>
every call to free() (or ast_frfree()) I check the pointer against NULL<br>
but it seems that frames are freed and the pointer isn&#39;t set to NULL.<br>
<br>
What I found out is that I had a dynamic sleep time at the start of<br>
every conference-mixing-loop. This was about 20000 usec (with usleep).<br>
It seems that decreasing this time to 1000 usec helps a little bit - the<br>
crash is not after 2 minutes or so but after 10 or 15 minutes...<br>
<br>
Has anyone an idea what I can do to find this problem?<br>
Are there helpful tools for this kind of problem?<br>
<br>
TIA, Holger<br>
--<br>
#####  #### ##  ##   Holger Wirtz         Phone : (+49 30) 884299-40<br>
##  ## ##   ### ##   DFN-Verein           Fax   : (+49 30) 884299-70<br>
##  ## #### ######   Alexanderplatz 1     E-Mail: <a href="mailto:wirtz@dfn.de">wirtz@dfn.de</a><br>
##  ## ##   ## ###   10178 Berlin<br>
#####  ##   ##  ##   GERMANY              WWW   : <a href="http://www.dfn.de" target="_blank">http://www.dfn.de</a><br>
GPG-Fingerprint: ABFA 1F51 DD8D 503C 85DC  0C51 E961 79E2 6685 9BCF<br>
<br>
_______________________________________________<br>
--Bandwidth and Colocation Provided by <a href="http://www.api-digital.com--" target="_blank">http://www.api-digital.com--</a><br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Prince Singh<br><br>Drishti-Soft Solutions Pvt Ltd<br>62-A, First Floor,<br>Maruti Industrial Area,<br>Sector - 18, Gurgaon - 122002<br>Haryana, India.<br> <br>
P: 91 124 4771000<br>F: 91 124 4039120<br>W: <a href="http://www.drishti-soft.com">http://www.drishti-soft.com</a><br>B: <a href="http://blog.drishti-soft.com">http://blog.drishti-soft.com</a><br>----<br>DISCLAIMER<br> <br>
This message may contain confidential, proprietary or legally Privileged information. In case you are not the original intended Recipient of the message, you must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message and you are requested to delete it and inform the sender.<br>
Any views expressed in this message are those of the individual sender unless otherwise stated. Nothing contained in this message shall be construed as an offer or acceptance of any offer by Drishti-Soft Solutions Pvt Ltd (&quot;Drishti&quot;) unless sent with that express intent and with due authority of Drishti.<br>
Drishti has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any virus transmitted by this email.<br>