[asterisk-users] Repeated Asterisk 10.7.0 crashes

kenner at gnat.com kenner at gnat.com
Tue Sep 4 23:04:10 CDT 2012


> There's a page on running Asterisk under valgrind on the wiki here:

Thanks for the pointer.  Valgrind wasn't needed since Asterisk MALLOC_DEBUG
was enough.

It took almost 1.5 hours in GDB, but I found it.  Because I was having
problems with res_speech_lumenvox, I was using UniMRCP, which uses Sofia-SIP.
But there's a bug:

*** su_uniqueid.c.old   2011-08-22 07:05:02.000000000 -0400
--- su_uniqueid.c       2012-09-04 23:46:02.000000000 -0400
***************
*** 100,104 ****
  
  static pthread_once_t once = PTHREAD_ONCE_INIT;
! static int done_once = 1;
  static pthread_key_t state_key;
  
--- 100,104 ----
  
  static pthread_once_t once = PTHREAD_ONCE_INIT;
! static int done_once = 0;
  static pthread_key_t state_key;
  
This was causing Sofia-SIP to call pthread_key_delete with a key that
wasn't actually created, meaning key 0.  Key 0 is used in Asterisk for
the thread storage for verbose_buf when MALLOC_DEBUG is enabled.
Deleting that key by itself didn't cause a problem, but mySQL's
initialization created another key, so 0 was reassigned.  When it
then used pthread_setspecific for its own purpose, it messed up
Asterisk's memory allocation.



More information about the asterisk-users mailing list