[asterisk-dev] Running a thread
Russell Bryant
russell at digium.com
Wed Jan 6 08:45:10 CST 2010
On 01/06/2010 01:36 AM, MohammedShehzad wrote:
> I made the thread detachable by replacing ast_pthread_create_background with
> below code:
> pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
> ast_pthread_create(&rtp->thread_var,&attr,
> ast_rtp_write_thread, rtp);
>
> It resolved the above leak, it seems that there is another leak too as
> below, which did not get resolved:
>
> ==3112== 1,241,886 bytes in 2,849 blocks are still reachable in loss record
> 41 of 41
> ==3112== at 0x4005525: malloc (vg_replace_malloc.c:149)
> ==3112== by 0x8075B0A: __ast_alloc_region (astmm.c:115)
> ==3112== by 0x8075AC5: __ast_calloc (astmm.c:198)
> ==3112== by 0x8120CFB: ast_threadstorage_get (threadstorage.h:130)
> ==3112== by 0x8121961: ast_store_lock_info (utils.c:551)
> ==3112== by 0x806BA56: __ast_pthread_mutex_lock (lock.h:369)
> ==3112== by 0x806B97C: ast_register_file_version (asterisk.c:281)
> ==3112== by 0x812091D: __register_file_version (utils.c:28)
> ==3112== by 0x814426A: (within /usr/sbin/asterisk)
> ==3112== by 0x8057A6C: (within /usr/sbin/asterisk)
> ==3112== by 0x8144138: __libc_csu_init (in /usr/sbin/asterisk)
> ==3112== by 0xB2D330: (below main) (in /lib/libc-2.7.so)
> ==3112==
Are you positive that the thread is actually exiting? If the thread
just does an invite loop, the thread is not going to actually exit, and
the thread local storage will not be destroyed (which is the leak you see).
--
Russell Bryant
Digium, Inc. | Engineering Manager, Open Source Software
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
www.digium.com -=- www.asterisk.org -=- blogs.asterisk.org
More information about the asterisk-dev
mailing list