PJSIP is core dumping on linux when the clock thread is destroyed.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



pjsip:

 

We are using version 2.5.5 on linux and have run into a major problem with pjmedia.

 

When we call pjmedia_master_port_destroy(), it, in turn, calls pjmedia_clock_destroy(). This is core-dumping on linux when glibc (we have a newer version compatible with gcc 6.1.0) tries to free the thread record that is stored in thread-local storage. The problem is that the thread record was allocated using pj_pool_zalloc() in pj_thread_create() (in os_core_unix.c). Unfortunately, glibc tries to free this memory using free() – in __nptl_deallocate_tsd, it core dumps because the memory address it is trying to free is not the memory address allocated by malloc(). Instead, it is offset by a linked-list pointer that is used internally by pj_pool_zalloc(). When it core dumps, you get an error message complaining that memory has been double-freed or corrupted. Neither is really the case, just the memory address passed to free is not what was allocated in malloc().

 

We created a kludge to fix this by simple using malloc() instead of pj_pool_zalloc().

 

Unfortunately, there are other race condition problems in pjmedia_clock_destroy(). In that file, it sets clock->quitting = PJ_TRUE. It then uses the pointer in thread-local storage for pj_thread_join() and pj_thread_destroy(). However, if you lose control of the CPU, the clock thread may actually end, its TLS be destroyed, and you will be accessing memory that has been freed. To get around this, you’ll need to make a copy of the thread record locally and use the local copy after setting clock->quitting to true.

 

Thanks.

 

David Ward

Thales

 

CONFIDENTIALITY NOTICE: This e-mail and any attachments are for the exclusive and confidential use of the intended recipient. If you received this in error, please do not read, distribute, or take action in reliance upon this message. Instead, please notify us immediately by return e-mail and promptly delete this message and its attachments from your computer system. We do not waive attorney-client or work product privilege by the transmission of this message. 4DX%oqAQ0nN1#i
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux