[Home]

Summary:ASTERISK-02597: Segfault when res_config_odbc and res_config_mysql are load
Reporter:apignard (apignard)Labels:
Date Opened:2004-10-13 17:49:42Date Closed:2011-06-07 14:00:59
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Applications/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:No problem when only one module is load.

When both module are load, no problem if we only use voicemail for res_config_odbc or/and voicemail/sip/iax with res_config_mysql.

Always segfault with sip or iax when using ODBC with or without res_config_mysql use, on the first sql query.

Here is sample configuration :
res_config_mysql.conf
[general]
dbhost = 1.1.1.1
dbname = asterisk
dbuser = user
dbpass = password

cat res_config_odbc.conf
[settings]
;table => sip
connection => mysql1

extconfig.conf
[settings]
;iaxfriends => mysql,asterisk,iax
;sipfriends => mysql,asterisk,sip

iaxfriends => odbc,mysql1,iax
sipfriends => odbc,mysql1,sip

res_odbc.conf
[mysql1]
dsn => mysql_asterisk
username => user
password => password
pre-connect => yes

/etc/odbc.ini
[ODBC Data Sources]

[mysql_asterisk]
Trace        = Off
TraceFile    = stderr
Driver       = MySQL
SERVER       = 1.1.1.1
USER         = user
PASSWORD     = password
Database     = asterisk
OPTION       = 3

#0  0x40f22bb6 in unireg_to_c_datatype () from /usr/lib/odbc/libmyodbc.so
(gdb) bt full
#0  0x40f22bb6 in unireg_to_c_datatype () from /usr/lib/odbc/libmyodbc.so
No symbol table info available.
#1  0x40f21e8f in fix_result_types () from /usr/lib/odbc/libmyodbc.so
No symbol table info available.
#2  0x00000000 in ?? ()
No symbol table info available.

First and last sql query :
SELECT * FROM sip WHERE name='myuser' limit 135523516
Comments:By: Brian West (bkw918) 2004-10-14 00:44:23

Does the problem show up with ODBC or MYSQl loaded individually?  
bkw

By: apignard (apignard) 2004-10-14 01:02:10

no problem when only load odbc or mysql

By: Brian West (bkw918) 2004-10-14 01:09:04

Um this is a libmyodbc issue... Try the latest unixODBC and MyODBC from src.

bkw

By: Mark Spencer (markster) 2004-10-20 00:24:00

Any progress here?

By: Ousmane Wilane (wilane) 2004-10-20 06:29:03

I can reproduce it using MyODBC(3.51.09) but it seems to disapear with unixODBC bundled MySQL driver.


Program received signal SIGSEGV, Segmentation fault.
0x41c71f04 in mysql_odbc_escape_string () from /usr/lib/mysql/libmysqlclient.so.10
(gdb) bt
#0  0x41c71f04 in mysql_odbc_escape_string () from /usr/lib/mysql/libmysqlclient.so.10
#1  0x41c2249f in insert_param () from /usr/lib/libmyodbc3.so
#2  0x41c21976 in insert_params () from /usr/lib/libmyodbc3.so
#3  0x41c22ad1 in my_SQLExecute () from /usr/lib/libmyodbc3.so
#4  0x41c22d4e in SQLExecute () from /usr/lib/libmyodbc3.so
ASTERISK-1  0x41a84245 in SQLExecute (statement_handle=0x8105600) at SQLExecute.c:283
ASTERISK-2  0x41b469bb in realtime_odbc (database=0x0, table=0xbffff020 "sip", ap=0xbffff250 "Lv\016\b") at res_config_odbc.c:101
ASTERISK-3  0x08057f54 in ast_load_realtime (family=0x0) at config.c:429
ASTERISK-4  0x41cb7415 in realtime_peer (peername=0x0, sin=0x815764c) at chan_sip.c:1058
ASTERISK-5  0x41cb3679 in find_peer (peer=0x8104266 "502", sin=0x0) at chan_sip.c:1132
ASTERISK-6 0x41caecbd in sip_show_peer (fd=1, argc=4, argv=0xbffff410) at chan_sip.c:5690
ASTERISK-7 0x0808002a in ast_cli_command (fd=1, s=0x0) at cli.c:1188
ASTERISK-8 0x0809e534 in main (argc=1103946672, argv=0xbffff410) at asterisk.c:705
ASTERISK-9 0x42015967 in __libc_start_main () from /lib/i686/libc.so.6

By: Brian West (bkw918) 2004-10-20 08:18:50

Odd since unixODBC doesn't come with any bundled MySQL drivers.  Can you show me your configs?

By: Ousmane Wilane (wilane) 2004-10-20 10:33:18

Oops here is what I'm calling unixODBC MySQL driver:

[root@SALAM unixODBC-2.2.10]# find ./* -type f -name libodbcmyS.*
./DRVConfig/MySQL/.libs/libodbcmyS.so.1.0.0
./DRVConfig/MySQL/.libs/libodbcmyS.lai
./DRVConfig/MySQL/libodbcmyS.la

I made them using the default ./configure --  --enable-drivers

Here is the relevant part of odbc.ini:
[mysql]
Trace    = Off
TraceFile= stderr
#Driver   = /usr/lib/libmyodbc3.so
Driver    = /usr/local/lib/libodbcmyS.so
DSN      = mysql
SERVER   = localhost
USER     = root
PASSWORD = *********
PORT     = 3306
#OPTIONS = 1
DATABASE= cdr
SOCKET  = /tmp/mysql.sock

You can get to the box if needed, I don't understand these things that much.

By: Brian West (bkw918) 2004-10-20 20:14:12

Can you try it with the "realtime" cli.  We haven't been able to reproduce this bug.  I wanna know if you can crash it with the cli .

bkw

By: Anthony Minessale (anthm) 2004-10-20 20:45:59

Ok despite the fact that I cannot figure out why you need res_config_mysql
when odbc already works with it , I tried to test it and cannot trigger
a seg


I hooked up iaxfriends to odbc and sipfriends to the mysql one
and registered both from firefly and can send/rec calls all day
sans segV

here is all the data I accumulated.....




show config handles



Config Engine: odbc
===> iaxfriends (db=asterisk, table=iax)

Config Engine: perl
===> demo (db=mysql1, table=demo)

Config Engine: sqlite
===> iqueues.conf (db=config, table=ast_config)

Config Engine: mysql
===> sipfriends (db=asterisk, table=sip)




*CLI> Oct 20 20:40:25 DEBUG[1144256960]: db.c:163 ast_db_get: Unable to find key 'whatever' in family 'IAX/Registry'
Oct 20 20:40:25 DEBUG[1133718080]: acl.c:176 ast_apply_ha: ##### Testing 10.3.3.249 with 10.3.3.0
Oct 20 20:40:25 DEBUG[1133718080]: res_config_mysql.c:97 realtime_mysql: MySQL RealTime: Retrieve SQL: SELECT * FROM sip WHERE name = 'whatever'
Oct 20 20:40:25 DEBUG[1144256960]: db.c:163 ast_db_get: Unable to find key 'whatever' in family 'IAX/Registry'
Oct 20 20:40:25 DEBUG[1133718080]: res_config_mysql.c:462 mysql_reconnect: MySQL RealTime: Everything is fine.
Oct 20 20:40:25 DEBUG[1144256960]: db.c:163 ast_db_get: Unable to find key 'whatever' in family 'IAX/Registry'
   -- SIP Seeding 'whatever' at whatever@10.3.3.249:5060 for 3600
Oct 20 20:40:25 DEBUG[1144256960]: db.c:163 ast_db_get: Unable to find key 'whatever' in family 'IAX/Registry'
Oct 20 20:40:25 DEBUG[1133718080]: res_config_mysql.c:97 realtime_mysql: MySQL RealTime: Retrieve SQL: SELECT * FROM sip WHERE name = 'whatever'
Oct 20 20:40:25 DEBUG[1133718080]: res_config_mysql.c:462 mysql_reconnect: MySQL RealTime: Everything is fine.
   -- SIP Seeding 'whatever' at whatever@10.3.3.249:5060 for 3600
Oct 20 20:40:25 DEBUG[1133718080]: res_config_mysql.c:186 update_mysql: MySQL RealTime: Update SQL: UPDATE sip SET ipaddr = '10.3.3.249', port = '5060', regseconds = '1098326425', username = 'whatever' WHERE name = 'whatever'
Oct 20 20:40:25 DEBUG[1133718080]: res_config_mysql.c:462 mysql_reconnect: MySQL RealTime: Everything is fine.
Oct 20 20:40:25 DEBUG[1133718080]: res_config_mysql.c:205 update_mysql: MySQL RealTime: Updated 1 rows on table: sip



realtime load iaxfriends name whatever
                  Column Name  Column Value
         --------------------  --------------------
                         name  whatever
                      context  speed_dial
                         host  dynamic
                         port  4569
                       secret  1234
                     username  whatever
                   regseconds  1098322825
                       ipaddr  10.3.3.249


realtime load sipfriends name whatever
Oct 20 20:41:07 DEBUG[1076245120]: res_config_mysql.c:97 realtime_mysql: MySQL RealTime: Retrieve SQL: SELECT * FROM sip WHERE name = 'whatever'
Oct 20 20:41:07 DEBUG[1076245120]: res_config_mysql.c:462 mysql_reconnect: MySQL RealTime: Everything is fine.
                  Column Name  Column Value
         --------------------  --------------------
                         name  whatever
                      context  speed_dial
                         host  dynamic
                         port  5060
                       secret  1234
                     username  whatever
                   regseconds  1098326425
                       ipaddr  10.3.3.249


realtime load demo name whatever
                  Column Name  Column Value
         --------------------  --------------------
                         name  fred
                          age  12


!cat /etc/asterisk/extconfig.conf
;
; Static and realtime external configuration
; engine configuration
;
[settings]
;
; Static configuration files:
;
; file.conf => driver,database[,table]
;
; maps a particular configuration file to the given
; database driver, database and table (or uses the
; name of the file as the table if not specified)
;
;uncomment to load queues.conf via the odbc engine.
;
;queues.conf => perl,mysql1,ast_config
iqueues.conf => sqlite,config,ast_config
;
; Realtime configuration engine
;
; maps a particular family of realtime
; configuration to a given database driver,
; database and table (or uses the name of
; the family if the table is not specified
;
;iaxfriends => odbc,asterisk
;iaxfriends => perl,perl
demo => perl,mysql1
sipfriends => mysql,asterisk,sip
iaxfriends => odbc,asterisk,iax


!cat /etc/asterisk/res_config_mysql.conf
[general]
dbhost = 10.3.3.104
dbname = asterisk
dbuser = myast
dbpass = astrox


!cat /etc/asterisk/res_odbc.conf
;;; odbc setup file

[asterisk]
dsn => MySQL-asterisk
pre-connect => yes


[asterisk2]
dsn => MySQL-asterisk
pre-connect => yes

By: Ousmane Wilane (wilane) 2004-10-21 02:58:03

1- I have no idea why the hell this config should be needed too, just
set it up to try reproduce this bug when I saw it reported.

2- Most of the time, I don't have access to the `realtime' cli, it just crash while loading (SIPRegInterval is 120 in my ATA 186) When I get a chance to
get there I get `random' (well! :) amount of time before the crash:


*CLI> realtime mysql status
Connected to cdr@localhost, port 3306 with username root for 17 seconds.
*CLI> realtime mysql status
Connected to cdr@localhost, port 3306 with username root for 18 seconds.
*CLI> realtime mysql status
Connected to cdr@localhost, port 3306 with username root for 19 seconds.
*CLI> realtime mysql status
Connected to cdr@localhost, port 3306 with username root for 19 seconds.
*CLI> realtime mysql status
Connected to cdr@localhost, port 3306 with username root for 20 seconds.
*CLI> Urgent handler
Urgent handler
Urgent handler
Urgent handler

*CLI> realtime mysql status
Connected to cdr@localhost, port 3306 with username root for 22 seconds.
*CLI> Urgent handler
Segmentation fault

3- This _ALWAYS_ happen with the binary odbc driver from MySQL folks
MyODBC-3.51.07-pc-linux-i686.tar.gz (while the same driver works with
isql -- see snapshot below --).

Here are all my config files:
-----------------------------
>> res_config_mysql.conf

[general]
dbhost=localhost
dbname=cdr
dbuser=root
dbpass=********
-----------------------------
>>  res_odbc.conf

;;; odbc setup file

[omnipay]
dsn => omnipay
username => root
password => ********
pre-connect => yes

[omnipay1]
dsn => omnipay1
username => root
pre-connect => yes

[mysql]
dsn => mysql
username => root
password => ********
pre-connect => yes
-----------------------------
>> extconfig.conf;
; Static and realtime external configuration
; engine configuration
;
[settings]
;
; Static configuration files:
;
; file.conf => driver,database[,table]
;
; maps a particular configuration file to the given
; database driver, database and table (or uses the
; name of the file as the table if not specified)
;
;uncomment to load queues.conf via the odbc engine.
;
queues.conf => odbc,omnipay,ast_config

;
; Realtime configuration engine
;
; maps a particular family of realtime
; configuration to a given database driver,
; database and table (or uses the name of
; the family if the table is not specified
;
iaxfriends => odbc,omnipay,iaxfriends
;sipfriends => odbc,omnipay,sipfriends
sipfriends => odbc,mysql,sip
;sipfriends => mysql,cdr,sip
voicemail => odbc,omnipay,voicemail
-----------------------------
>> odbc.ini

[omnipay]
Description             = Psql
Driver          = PostgreSQL
Trace           = Yes
TraceFile               =
Database                = omnipay
Servername              = localhost
Username                = root
Password                = ********
Port            = 5432
Protocol                = 6.4
ReadOnly                = No
RowVersioning           = No
ShowSystemTables                = No
ShowOidColumn           = No
FakeOidIndex            = No
ConnSettings            =


[omnipay1]
Description=SQLite
Driver=SQLite
Database=/etc/asterisk/omnipay.db
# optional lock timeout in milliseconds
Timeout=9000
Trace           = Yes
TraceFile               = /tmp/sqlite.log


[mysql]
Trace    = Off
TraceFile= stderr
Driver   = /usr/lib/libmyodbc3.so
DSN      = mysql
SERVER   = localhost
USER     = root
PASSWORD = ********
PORT     = 3306
#OPTIONS = 1
DATABASE= cdr
SOCKET  = /tmp/mysql.sock
-----------------------------

#0  0x41c8bf04 in mysql_odbc_escape_string ()
  from /usr/lib/mysql/libmysqlclient.so.10
#1  0x41c1c49f in insert_param () from /usr/lib/libmyodbc3.so
#2  0x41c1b976 in insert_params () from /usr/lib/libmyodbc3.so
#3  0x41c1cad1 in my_SQLExecute () from /usr/lib/libmyodbc3.so
#4  0x41c1cd4e in SQLExecute () from /usr/lib/libmyodbc3.so
ASTERISK-1  0x41a86245 in SQLExecute (statement_handle=0x8199358) at SQLExecute.c:283
ASTERISK-2  0x41b5a9bb in realtime_odbc (database=0x0, table=0x41ee380c "sip",
   ap=0x41ee3a3c "") at res_config_odbc.c:101
ASTERISK-3  0x08057f54 in ast_load_realtime (family=0x0) at config.c:429
ASTERISK-4  0x41cd1415 in realtime_peer (peername=0x0, sin=0x8157244)
   at chan_sip.c:1058
ASTERISK-5  0x41ccd679 in find_peer (peer=0x41ee3be1 "503", sin=0x0) at chan_sip.c:1132
ASTERISK-6 0x41cd8b4b in register_verify (p=0x819f320, sin=0x41ee776c,
   req=0x41ee777c, uri=0x41ee7999 "sip:192.168.1.67", ignore=0)
   at chan_sip.c:4769
ASTERISK-7 0x41cd4a6a in handle_request (p=0x819f320, req=0x41ee777c, sin=0x41ee776c,
   recount=0x0, nounlock=0x41ee7700) at chan_sip.c:7499
ASTERISK-8 0x41ccfe1e in sipsock_read (id=0x8175c30, fd=21, events=1, ignore=0x0)
   at chan_sip.c:7597
ASTERISK-9 0x0805249f in ast_io_wait (ioc=0x815d998, howlong=0) at io.c:267
ASTERISK-10 0x41cca695 in do_monitor (data=0x0) at chan_sip.c:7745
ASTERISK-11 0x4003e881 in pthread_detach () from /lib/i686/libpthread.so.0

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

And From  isql cli :

[root@SALAM src]# isql mysql root ********
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select * from sip where name like 'abm%';
+-----+------------+---------+----------+---------+------------+--------+----------+---------+---------+-----------+
-----+--------------+--------------+---------+---------+--------+----------+----+-------+-----+------------+-----+--
------+------------+-----------+---------------+-------+-----+---------+------+---------+-----------+-------+-----+-
--------+----------+
| name| accountcode| amaflags| callgroup| callerid| canreinvite| context| defaultip| dtmfmode| fromuser| fromdomain|
host| incominglimit| outgoinglimit| insecure| language| mailbox| md5secret| nat| permit| deny| pickupgroup| port| q
ualify| restrictcid| rtptimeout| rtpholdtimeout| secret| type| username| allow| disallow| regseconds| ipaddr| auth|
externip| useragent|
+-----+------------+---------+----------+---------+------------+--------+----------+---------+---------+-----------+
-----+--------------+--------------+---------+---------+--------+----------+----+-------+-----+------------+-----+--
------+------------+-----------+---------------+-------+-----+---------+------+---------+-----------+-------+-----+-
--------+----------+
+-----+------------+---------+----------+---------+------------+--------+----------+---------+---------+-----------+
-----+--------------+--------------+---------+---------+--------+----------+----+-------+-----+------------+-----+--
------+------------+-----------+---------------+-------+-----+---------+------+---------+-----------+-------+-----+-
--------+----------+
SQLRowCount returns 0
SQL>

By: Anthony Minessale (anthm) 2004-10-21 08:56:31

hmm mine wont die are these seging tests being performed on latest cvs
that has been made clean and made install perhaps find me on irc so I
can see the reproducable env.

or how bout a "bt full" from the regular bt i did notice this:
in frame 6 "database" = NULL
in frame 7 "family" = NULL
in frame 8 "peername" = "NULL"

0000005 0x41a86245 in SQLExecute (statement_handle=0x8199358) at SQLExecute.c:283
0000006 0x41b5a9bb in realtime_odbc (database=0x0, table=0x41ee380c "sip",
   ap=0x41ee3a3c "") at res_config_odbc.c:101
0000007 0x08057f54 in ast_load_realtime (family=0x0) at config.c:429
0000008 0x41cd1415 in realtime_peer (peername=0x0, sin=0x8157244)
   at chan_sip.c:1058


I can enter realtime mysql status endlessly

*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 4 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 5 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 5 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 5 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 6 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 6 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 6 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 7 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 7 seconds.
*CLI> realtime mysql status
Connected to asterisk@10.3.3.104, port 3306 with username myast for 12 hours, 15 minutes, 7 seconds.

By: Anthony Minessale (anthm) 2004-10-21 12:12:00

Install the newest verison of libmyodbc3.so the test box
donated by wilane has led me to to conculusion that the
existing libmyodbc3.so or libodbcmyS.so are at fault after installing
the one from my box it works fine It may be because those driver are
not theadsafe.

By: Brian West (bkw918) 2004-10-27 19:24:35

This was something anthm and I worked for HOURS on and couldn't reproduce in our env.  He was able to fix the reporters issue.  It was bum libmyodbc that was at fault.

bkw