[Home]

Summary:ASTERISK-04981: Asterisk segfaults when loading chan_sip without sip.conf (or realtime database)
Reporter:David James (davidj)Labels:
Date Opened:2005-09-04 19:39:44Date Closed:2008-01-15 15:48:12.000-0600
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) gdb.txt
Description:Asterisk will core dump when Mysql is down. Apparently it tries to grab sip.conf information and crashes.  Shouldn't all variables be checked before loaded?

Possibly problem with other database drivers.

Expected results: gracefully stop, or better infinitely try to reconnect/ wait until success.


****** ADDITIONAL INFORMATION ******

[root@comcast root]# /etc/init.d/mysqld  stop
[root@comcast root]# asterisk -vdgc
...
MySQL RealTime driver loaded.
[chan_sip.so] => (Session Initiation Protocol (SIP))
Sep  4 17:33:15 ERROR[32209]: res_config_mysql.c:596 mysql_reconnect: MySQL RealTime: Failed to connect database server asterisk_realtime on localhost. Check debug for more info.
Sep  4 17:33:15 NOTICE[32209]: chan_sip.c:11441 reload_config: Unable to load config sip.conf
Sep  4 17:33:15 WARNING[32209]: loader.c:403 __load_resource: chan_sip.so: load_module failed, returning -1
Segmentation fault (core dumped)
[root@comcast root]# Ouch ... error while writing audio data: : Broken pipe
Ouch ... error while writing audio data: : Broken pipe
Ouch ... error while writing audio data: : Broken pipe

\


gdb.txt contains more information Thanks
Comments:By: David James (davidj) 2005-09-04 19:42:12

Sorry this should be a 'Crash' bug and it is not about Code Formatting/comments

By: Michael Jerris (mikej) 2005-09-05 08:07:28

Bugs in modules outside of the main asterisk project are not considered crash bugs.

By: Donny Kavanagh (donnyk) 2005-09-06 07:02:34

David, could you possibly test to see if this occurs with the ODBC driver. (vs mysql)  This will determine then if the bug is indeed within asterisk directally, or within the Mysql Realtime driver (which comes from asterisk-addons)

Thanks

By: David James (davidj) 2005-09-06 13:40:04

If you look at the bug report (MikeJ this means you) the last message is
chan_sip.so crapping out.  Notice the mysql stuff is fine.

Now if I modify modules.conf to use noload res_config_mysql, and use
unixODBC I get the same results.


[app_realtime.so] => (Realtime Data Lookup/Rewrite)
[res_config_odbc.so] => (ODBC Configuration)
Sep  6 11:26:46 NOTICE[29301]: config.c:836 ast_config_engine_register: Registered Config Engine odbc
res_config_odbc loaded.
[res_odbc.so] => (ODBC Resource)
Sep  6 11:26:46 DEBUG[29301]: config.c:568 config_text_file_load: Parsing /etc/asterisk/res_odbc.conf
Sep  6 11:26:46 NOTICE[29301]: res_odbc.c:215 load_odbc_config: registered database handle 'asterisk' dsn->[default]
Sep  6 11:26:46 NOTICE[29301]: res_odbc.c:473 odbc_obj_connect: Connecting asterisk
Sep  6 11:26:46 WARNING[29301]: res_odbc.c:484 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=2002 [unixODBC][TCX][MyODBC]Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.soc

...

[chan_sip.so] => (Session Initiation Protocol (SIP))
Sep  6 11:26:46 DEBUG[29301]: channel.c:293 ast_channel_register: Registered handler for 'SIP' (Session Initiation Protocol (SIP))
Sep  6 11:26:46 WARNING[29301]: config.c:893 find_engine: Realtime mapping for 'sip.conf' found to engine 'mysql', but the engine is not available
Sep  6 11:26:46 DEBUG[29301]: config.c:634 config_text_file_load: No file to parse: /etc/asterisk/sip.conf
Sep  6 11:26:46 NOTICE[29301]: chan_sip.c:11441 reload_config: Unable to load config sip.conf
Sep  6 11:26:46 WARNING[29301]: loader.c:403 __load_resource: chan_sip.so: load_module failed, returning -1
Sep  6 11:26:46 DEBUG[29301]: channel.c:308 ast_channel_unregister: Unregistering channel type 'SIP'

BTW I use mysql because res_ODBC makes Asterisk run so buggy it won't even work half the time.  I will spend some effort tracing these bugs if people will read the bug reports.

By: Donny Kavanagh (donnyk) 2005-09-06 13:49:42

Looks like a problem to me, i'm not sure who maintains sip in relation to realtime, but while we are on the topic i would say that realtime is a little messy.  In relation to chan_sip & realtime, there are two different table formats.  One for when you are using realtime static, and one for realtime dynamic.  Why the hell would we do this?

Anyways, hopefully oej or kp will ping in on this soon.

By: David James (davidj) 2005-09-06 14:22:03

Yes I am using in extconfig for both sip.conf and Asterisk realtime.
I am using it succesfully in production although there is a bug regarding
the order of Allow/Disallow which causes chan_sip.so undefined behavior. (will open a new bug soon)

sip.conf  => odbc,asterisk,ast_config

and

sipusers => odbc,asterisk,users
sippeers => odbc,asterisk,users

case 1:

If I use driver mysql it core dumps on chan_sip.so

case 2:

If I use odbc driver, and only this change to my configuration, Asterisk crashes but without a core dump.  Furthermore Asterisk stops (correctly??) when trying to access modem.conf


[chan_modem.so] => (Generic Voice Modem Driver)
Sep  6 12:20:20 DEBUG[29728]: res_config_mysql.c:373 config_mysql: MySQL RealTime: Static SQL: SELECT category, var_name, var_val, cat_metric FROM ast_config WHERE filename='modem.conf' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id
Sep  6 12:20:20 ERROR[29728]: res_config_mysql.c:605 mysql_reconnect: MySQL RealTime: Failed to connect database server asterisk_realtime on . Check debug for more info.
Sep  6 12:20:20 DEBUG[29728]: res_config_mysql.c:606 mysql_reconnect: MySQL RealTime: Cannot Connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Sep  6 12:20:20 ERROR[29728]: chan_modem.c:981 load_module: Unable to load config modem.conf
Sep  6 12:20:20 WARNING[29728]: loader.c:403 __load_resource: chan_modem.so: load_module failed, returning -1
Sep  6 12:20:20 DEBUG[29728]: channel.c:308 ast_channel_unregister: Unregistering channel type 'Modem'
Sep  6 12:20:20 WARNING[29728]: loader.c:488 load_modules: Loading module chan_modem.so failed!



case 3:

ODBC; Modified modules.conf to load res_features.so and chan_sip.so before chan_modem.so: core dump, same behavior as case 1

Here is the output:


#0  0x00982920 in pthread_cancel () from /lib/tls/libpthread.so.0
(gdb) info thread
 5 process 29655  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
 4 process 29656  accept_thread (ignore=0x0) at manager.c:1364
 3 process 29657  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
 2 process 29658  do_parking_thread (ignore=0xb7d26bb0) at res_features.c:1441
* 1 process 29653  0x00982920 in pthread_cancel () from /lib/tls/libpthread.so.0
(gdb) thread apply all bt

Thread 5 (process 29655):
#0  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
#1  0x00872404 in poll () from /lib/tls/libc.so.6
#2  0x080b120d in listener (unused=0x0) at asterisk.c:495
#3  0x0097f341 in __pthread_initialize_minimal () from /lib/tls/libpthread.so.0
#4  0x0087bfee in clone () from /lib/tls/libc.so.6

Thread 4 (process 29656):
#0  accept_thread (ignore=0x0) at manager.c:1364
#1  0x0097f341 in __pthread_initialize_minimal () from /lib/tls/libpthread.so.0
#2  0x0087bfee in clone () from /lib/tls/libc.so.6

Thread 3 (process 29657):
#0  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
#1  0x00981a86 in pthread_cond_wait () from /lib/tls/libpthread.so.0
#2  0x080c3619 in do_devstate_changes (data=0x0) at devicestate.c:238
#3  0x0097f341 in __pthread_initialize_minimal () from /lib/tls/libpthread.so.0
#4  0x0087bfee in clone () from /lib/tls/libc.so.6

Thread 2 (process 29658):
#0  do_parking_thread (ignore=0xb7d26bb0) at res_features.c:1441
#1  0x0097f341 in __pthread_initialize_minimal () from /lib/tls/libpthread.so.0
#2  0x0087bfee in clone () from /lib/tls/libc.so.6

Thread 1 (process 29653):
#0  0x00982920 in pthread_cancel () from /lib/tls/libpthread.so.0
#1  0x001b56e0 in unload_module () at chan_sip.c:12283
#2  0x0805a8fd in ast_unload_resource (resource_name=0x868549d "chan_sip.so", force=0) at loader.c:129
#3  0x0805b766 in __load_resource (resource_name=0x868549d "chan_sip.so", cfg=0x1) at loader.c:404
#4  0x0805b8dc in load_modules (preload_only=0) at loader.c:487
ASTERISK-1  0x080b539a in main (argc=2, argv=0xbfe056a4) at asterisk.c:2127
(gdb)




case 4:

Using changes from case 3 with MySQL driver in extconfig.conf and disabling modules res_config_odbc.so and res_odbc.so, enabling module res_config_mysql.so: core dump, same ase case 3 and case 1

Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /usr/lib/asterisk/modules/res_features.so...done.
Loaded symbols for /usr/lib/asterisk/modules/res_features.so
Reading symbols from /usr/lib/asterisk/modules/chan_sip.so...done.
Loaded symbols for /usr/lib/asterisk/modules/chan_sip.so
#0  0x00982920 in pthread_cancel () from /lib/tls/libpthread.so.0
(gdb) info thread
 5 process 29679  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
 4 process 29680  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
 3 process 29681  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
 2 process 29682  do_parking_thread (ignore=0xb7f2dbb0) at res_features.c:1441
* 1 process 29677  0x00982920 in pthread_cancel () from /lib/tls/libpthread.so.0
(gdb)  thread apply all bt

Thread 5 (process 29679):
#0  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
#1  0x00872404 in poll () from /lib/tls/libc.so.6
#2  0x080b120d in listener (unused=0x0) at asterisk.c:495
#3  0x0097f341 in __pthread_initialize_minimal () from /lib/tls/libpthread.so.0
#4  0x0087bfee in clone () from /lib/tls/libc.so.6

Thread 4 (process 29680):
#0  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
#1  0x00984608 in accept () from /lib/tls/libpthread.so.0
#2  0x080aee2b in accept_thread (ignore=0x0) at manager.c:1379
#3  0x0097f341 in __pthread_initialize_minimal () from /lib/tls/libpthread.so.0
#4  0x0087bfee in clone () from /lib/tls/libc.so.6

Thread 3 (process 29681):
#0  0x0079c7a2 in ?? () from /lib/ld-linux.so.2
#1  0x00981a86 in pthread_cond_wait () from /lib/tls/libpthread.so.0
#2  0x080c3619 in do_devstate_changes (data=0x0) at devicestate.c:238
#3  0x0097f341 in __pthread_initialize_minimal () from /lib/tls/libpthread.so.0
#4  0x0087bfee in clone () from /lib/tls/libc.so.6

Thread 2 (process 29682):
#0  do_parking_thread (ignore=0xb7f2dbb0) at res_features.c:1441
#1  0x0097f341 in __pthread_initialize_minimal () from /lib/tls/libpthread.so.0
#2  0x0087bfee in clone () from /lib/tls/libc.so.6

Thread 1 (process 29677):
#0  0x00982920 in pthread_cancel () from /lib/tls/libpthread.so.0
#1  0x002a76e0 in unload_module () at chan_sip.c:12283
#2  0x0805a8fd in ast_unload_resource (resource_name=0x84ac3ed "chan_sip.so", force=0) at loader.c:129
#3  0x0805b766 in __load_resource (resource_name=0x84ac3ed "chan_sip.so", cfg=0x1) at loader.c:404
#4  0x0805b8dc in load_modules (preload_only=0) at loader.c:487
ASTERISK-1  0x080b539a in main (argc=2, argv=0xbfed04f4) at asterisk.c:2127
(gdb)


case 5:
Disable all chan_sip.
Enable chan_iax2 higher module loading prority
Results: Asterisk stop on chan_modem.so

[res_crypto.so] => (Cryptographic Digital Signatures)
Sep  6 12:20:20 DEBUG[29728]: res_crypto.c:246 try_load_key: Key 'freeworlddialup' loaded OK
Sep  6 12:20:20 DEBUG[29728]: res_crypto.c:246 try_load_key: Key 'iaxtel' loaded OK
[chan_iax2.so] => (Inter Asterisk eXchange (Ver 2))
Sep  6 12:20:20 WARNING[29728]: chan_iax2.c:9354 load_module: Unable to open IAX timing interface: No such file or directory
Sep  6 12:20:20 DEBUG[29728]: res_config_mysql.c:373 config_mysql: MySQL RealTime: Static SQL: SELECT category, var_name, var_val, cat_metric FROM ast_config WHERE filename='iax.conf' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id
Sep  6 12:20:20 ERROR[29728]: res_config_mysql.c:605 mysql_reconnect: MySQL RealTime: Failed to connect database server asterisk_realtime on . Check debug for more info.
Sep  6 12:20:20 DEBUG[29728]: res_config_mysql.c:606 mysql_reconnect: MySQL RealTime: Cannot Connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Sep  6 12:20:20 ERROR[29728]: chan_iax2.c:8421 set_config: Unable to load config iax.conf
Sep  6 12:20:20 DEBUG[29728]: channel.c:293 ast_channel_register: Registered handler for 'IAX2' (Inter Asterisk eXchange Driver (Ver 2))
Sep  6 12:20:20 DEBUG[29728]: res_config_mysql.c:373 config_mysql: MySQL RealTime: Static SQL: SELECT category, var_name, var_val, cat_metric FROM ast_config WHERE filename='iaxprov.conf' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id
Sep  6 12:20:20 ERROR[29728]: res_config_mysql.c:605 mysql_reconnect: MySQL RealTime: Failed to connect database server asterisk_realtime on . Check debug for more info.
Sep  6 12:20:20 DEBUG[29728]: res_config_mysql.c:606 mysql_reconnect: MySQL RealTime: Cannot Connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Sep  6 12:20:20 NOTICE[29728]: iax2-provision.c:504 iax_provision_reload: No IAX provisioning configuration found, IAX provisioning disabled.
[chan_modem.so] => (Generic Voice Modem Driver)
Sep  6 12:20:20 DEBUG[29728]: res_config_mysql.c:373 config_mysql: MySQL RealTime: Static SQL: SELECT category, var_name, var_val, cat_metric FROM ast_config WHERE filename='modem.conf' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id
Sep  6 12:20:20 ERROR[29728]: res_config_mysql.c:605 mysql_reconnect: MySQL RealTime: Failed to connect database server asterisk_realtime on . Check debug for more info.
Sep  6 12:20:20 DEBUG[29728]: res_config_mysql.c:606 mysql_reconnect: MySQL RealTime: Cannot Connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Sep  6 12:20:20 ERROR[29728]: chan_modem.c:981 load_module: Unable to load config modem.conf
Sep  6 12:20:20 WARNING[29728]: loader.c:403 __load_resource: chan_modem.so: load_module failed, returning -1
Sep  6 12:20:20 DEBUG[29728]: channel.c:308 ast_channel_unregister: Unregistering channel type 'Modem'
Sep  6 12:20:20 WARNING[29728]: loader.c:488 load_modules: Loading module chan_modem.so failed!

By: Olle Johansson (oej) 2005-09-06 14:34:06

Did it crash with odbc?

By: Olle Johansson (oej) 2005-09-06 14:44:39

Succeded in generating a crash. backtrace useless.

By: David James (davidj) 2005-09-06 14:45:38

Yes.

By: David James (davidj) 2005-09-06 14:47:24

Can somebody explain how is this an experimental feature; its listed as an item on the 1.2 release email. Thanks

By: Olle Johansson (oej) 2005-09-06 15:10:01

I think we can forget about realtime. Disable realtime and start asterisk without a sip.conf and it will crash.

Chan_iax2 loads without config file. Must be the way we return -1 on load_module

By: Donny Kavanagh (donnyk) 2005-09-06 17:34:39

I actually noticed this a long time ago, eg months, and forgot to report it.  Oops.

I just checked, and on CVS-STABLE this does not occur, it reports the file as missing, and gracefully continues.  It infact loads the sip module, without any peers.

By: Kevin P. Fleming (kpfleming) 2005-09-13 22:53:52

This should be fixed in CVS HEAD now.

By: Digium Subversion (svnbot) 2008-01-15 15:48:12.000-0600

Repository: asterisk
Revision: 6590

U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r6590 | kpfleming | 2008-01-15 15:48:12 -0600 (Tue, 15 Jan 2008) | 3 lines

don't abort Asterisk load if configuration not found (issue ASTERISK-4981)
don't register channel type until after config has been loaded

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=6590