[Home]

Summary:ASTERISK-13660: Segmentation fault caused by sqlite3_log
Reporter:Alejandro Rios P. (alerios)Labels:
Date Opened:2009-02-26 13:12:31.000-0600Date Closed:2009-03-02 11:16:58.000-0600
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:CDR/cdr_sqlite3_custom
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Asterisk 1.6.0.5 randomly crashes, apparently because of the cdr_sqlite3_custom module.

I'm using debian etch, with these versions of libsqlite:

ii  libsqlite3-0         3.3.8-1.1            SQLite 3 shared library
ii  libsqlite3-dev       3.3.8-1.1            SQLite 3 development files



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

This is the backtrace:

Core was generated by `/usr/sbin/asterisk -F -g -vvv -p -g -U asterisk'.
Program terminated with signal 11, Segmentation fault.
#0  0xb7111f66 in sqlite3SafetyOn () from /usr/lib/libsqlite3.so.0
(gdb) backtrace
#0  0xb7111f66 in sqlite3SafetyOn () from /usr/lib/libsqlite3.so.0
#1  0xb7105e97 in sqlite3_prepare () from /usr/lib/libsqlite3.so.0
#2  0xb7122a56 in sqlite3_exec () from /usr/lib/libsqlite3.so.0
#3  0xb713ae7f in sqlite3_log (cdr=0x85890d8) at cdr_sqlite3_custom.c:274
#4  0x08084186 in post_cdr (cdr=0x85890d8) at cdr.c:1021
ASTERISK-1  0x080843a8 in ast_cdr_detach (cdr=0x85890d8) at cdr.c:1217
ASTERISK-2  0x080b2b02 in ast_bridge_call (chan=0xb5f02628, peer=0x8573a90, config=0xb5e05da8)
   at features.c:2246
ASTERISK-3  0xb7219306 in dial_exec_full (chan=0xb5f02628, data=0xb5e07f38, peerflags=0xb5e05e90,
   continue_exec=0x0) at app_dial.c:1959
ASTERISK-4  0xb721e819 in dial_exec (chan=0xb5f02628, data=0xb5e07f38) at app_dial.c:2023
ASTERISK-5  0x080e6a39 in pbx_exec (c=0xb5f02628, app=0x81c0e20, data=0xb5e07f38) at pbx.c:944
ASTERISK-6 0x080f26f1 in pbx_extension_helper (c=0xb5f02628, con=0x0, context=0xb5f027b0 "macro-local",
   exten=0xb5f02800 "s", priority=13, label=0x0, callerid=0xb5f08600 "19", action=E_SPAWN,
   found=0xb5e0aef4, combined_find_spawn=1) at pbx.c:3113
ASTERISK-7 0xb720f430 in _macro_exec (chan=0xb5f02628, data=<value optimized out>, exclusive=0)
   at app_macro.c:295
ASTERISK-8 0x080e6a39 in pbx_exec (c=0xb5f02628, app=0x8507b30, data=0xb5e0cfb8) at pbx.c:944
ASTERISK-9 0x080f26f1 in pbx_extension_helper (c=0xb5f02628, con=0x0, context=0xb5f027b0 "macro-local",
   exten=0xb5f02800 "s", priority=4, label=0x0, callerid=0xb5f08600 "19", action=E_SPAWN,
   found=0xb5e0f3f8, combined_find_spawn=1) at pbx.c:3113
ASTERISK-10 0x080f4d05 in __ast_pbx_run (c=0xb5f02628) at pbx.c:3606
ASTERISK-11 0x080f653e in pbx_thread (data=0xb5f02628) at pbx.c:3956
ASTERISK-12 0x081306b0 in dummy_start (data=0xb5f036d8) at utils.c:917
ASTERISK-13 0xb7ce2240 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
ASTERISK-14 0xb7dbe49e in clone () from /lib/tls/i686/cmov/libc.so.6
Comments:By: Tilghman Lesher (tilghman) 2009-02-26 13:55:38.000-0600

This is a known issue in SQLite.  Please see http://www.sqlite.org/cvstrac/tktview?tn=3059 for the fixed version.

By: Alejandro Rios P. (alerios) 2009-02-27 14:57:43.000-0600

Ok, now I'm using sqlite3_3.5.9, with the patch you say applied (http://www.sqlite.org/cvstrac/chngview?cn=5016), and I'm still getting a segfault, but this time the backtrace is a bit different:

Core was generated by `/usr/sbin/asterisk -F -g -vvv -p -g -U asterisk'.
Program terminated with signal 11, Segmentation fault.
#0  sqlite3_exec (db=0x0,
   zSql=0x83ea978 "INSERT INTO cdr (clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,start,answer,end,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield,pbx,intrunk,outtrunk,dialout) VALUES ('"..., xCallback=0, pArg=0x0, pzErrMsg=0xb5d0bbd8) at sqlite3.c:60343
60343  sqlite3_mutex_enter(db->mutex);
(gdb) backtrace
#0  sqlite3_exec (db=0x0,
   zSql=0x83ea978 "INSERT INTO cdr (clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,start,answer,end,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield,pbx,intrunk,outtrunk,dialout) VALUES ('"..., xCallback=0, pArg=0x0, pzErrMsg=0xb5d0bbd8) at sqlite3.c:60343
#1  0xb76c6e7f in sqlite3_log (cdr=0x8614818) at cdr_sqlite3_custom.c:274
#2  0x08084186 in post_cdr (cdr=0x8614818) at cdr.c:1021
#3  0x080843a8 in ast_cdr_detach (cdr=0x8614818) at cdr.c:1217
#4  0x080b2b02 in ast_bridge_call (chan=0x86540c0, peer=0x84ff450, config=0xb5d0cd98)
   at features.c:2246
ASTERISK-1  0xb6061306 in dial_exec_full (chan=0x86540c0, data=0xb5d0ef28, peerflags=0xb5d0ce80,
   continue_exec=0x0) at app_dial.c:1959
ASTERISK-2  0xb6066819 in dial_exec (chan=0x86540c0, data=0xb5d0ef28) at app_dial.c:2023
ASTERISK-3  0x080e6a39 in pbx_exec (c=0x86540c0, app=0x837cd08, data=0xb5d0ef28) at pbx.c:944
ASTERISK-4  0x080f26f1 in pbx_extension_helper (c=0x86540c0, con=0x0,
   context=0x8654248 "macro-dial-std-exten", exten=0x8654298 "s", priority=21, label=0x0,
   callerid=0x82ec908 "dsec=25", action=E_SPAWN, found=0xb5d11ef4, combined_find_spawn=1)
   at pbx.c:3113
ASTERISK-5  0xb6057430 in _macro_exec (chan=0x86540c0, data=<value optimized out>, exclusive=0)
   at app_macro.c:295
ASTERISK-6 0x080e6a39 in pbx_exec (c=0x86540c0, app=0x8532058, data=0xb5d13fb8) at pbx.c:944
ASTERISK-7 0x080f26f1 in pbx_extension_helper (c=0x86540c0, con=0x0,
   context=0x8654248 "macro-dial-std-exten", exten=0x8654298 "s", priority=4, label=0x0,
   callerid=0x82ec908 "dsec=25", action=E_SPAWN, found=0xb5d163f8, combined_find_spawn=1)
   at pbx.c:3113
ASTERISK-8 0x080f4d05 in __ast_pbx_run (c=0x86540c0) at pbx.c:3606
ASTERISK-9 0x080f653e in pbx_thread (data=0x86540c0) at pbx.c:3956
---Type <return> to continue, or q <return> to quit---
ASTERISK-10 0x081306b0 in dummy_start (data=0x85258b0) at utils.c:917
ASTERISK-11 0xb7cd4240 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
ASTERISK-12 0xb7db049e in clone () from /lib/tls/i686/cmov/libc.so.6
(gdb)

By: Digium Subversion (svnbot) 2009-02-27 15:32:13.000-0600

Repository: asterisk
Revision: 179161

U   trunk/cdr/cdr_sqlite3_custom.c

------------------------------------------------------------------------
r179161 | tilghman | 2009-02-27 15:32:13 -0600 (Fri, 27 Feb 2009) | 3 lines

If config file is blank, don't load module.
(Closes issue ASTERISK-13660)

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

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

By: Digium Subversion (svnbot) 2009-02-27 15:33:31.000-0600

Repository: asterisk
Revision: 179162

_U  branches/1.6.0/
U   branches/1.6.0/cdr/cdr_sqlite3_custom.c

------------------------------------------------------------------------
r179162 | tilghman | 2009-02-27 15:33:31 -0600 (Fri, 27 Feb 2009) | 10 lines

Merged revisions 179161 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r179161 | tilghman | 2009-02-27 15:32:13 -0600 (Fri, 27 Feb 2009) | 3 lines
 
 If config file is blank, don't load module.
 (Closes issue ASTERISK-13660)
........

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

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

By: Digium Subversion (svnbot) 2009-02-27 15:34:11.000-0600

Repository: asterisk
Revision: 179163

_U  branches/1.6.1/
U   branches/1.6.1/cdr/cdr_sqlite3_custom.c

------------------------------------------------------------------------
r179163 | tilghman | 2009-02-27 15:34:11 -0600 (Fri, 27 Feb 2009) | 10 lines

Merged revisions 179161 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r179161 | tilghman | 2009-02-27 15:32:13 -0600 (Fri, 27 Feb 2009) | 3 lines
 
 If config file is blank, don't load module.
 (Closes issue ASTERISK-13660)
........

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

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

By: Alejandro Rios P. (alerios) 2009-02-27 17:03:20.000-0600

I'm sorry for being nasty, but I'm still getting the segfault, even after applying the new patch. I guess it might be something wrong with my configs, but I just can't figure out what it is.

Here is my /etc/asterisk/cdr_sqlite3_custom.conf (just as I use it on asterisk 1.4.X):

-----------------------------------
[master]
table => cdr
columns => clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,start,answer,
end,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield,
pbx,intrunk,outtrunk,dialout
values => '${CDR(clid)}','${CDR(src)}','${CDR(dst)}','${CDR(dcontext)}','${CDR(channel)}',
'${CDR(dstchannel)}','${CDR(lastapp)}','${CDR(lastdata)}','${CDR(start)}',
'${CDR(answer)}','${CDR(end)}','${CDR(duration)}','${CDR(billsec)}','${CDR(disposition)}',
'${CDR(amaflags)}','${CDR(accountcode)}','${CDR(uniqueid)}','${CDR(userfield)}','${CDR(pbx)}',
'${CDR(intrunk)}','${CDR(outtrunk)}','${CDR(dialout)}'
-----------------------------------



And here is the strace output:


-----------------------------------
[090227-174346] DEBUG[4925]: channel.c:1636 ast_hangup: Hanging up channel 'SIP/alerios-083559b0'
[090227-174346] DEBUG[4925]: chan_sip.c:4852 sip_hangup: Hangup call SIP/alerios-083559b0, SIP callid 99ed9f0c-42490839-cc62179a@172.30.0.13
[090227-174346] DEBUG[4925]: chan_sip.c:4499 update_call_counter: Updating call counter for incoming call
[090227-174346] DEBUG[4925]: devicestate.c:450 ast_devstate_changed_literal: Notification of state change to be queued on device/channel SIP/alerios
[090227-174346] DEBUG[4925]: pbx.c:2928 pbx_substitute_variables_helper_full: Function result is '"Alejandro Rios Peña" <25>'
[090227-174346] DEBUG[4925]: pbx.c:2928 pbx_substitute_variables_helper_full: Function result is '25'
0xbfb7f29b, 1)                  = ? ERESTARTSYS (To be restarted)
+++ killed by SIGSEGV +++
Process 4864 detached
-----------------------------------



By: Tilghman Lesher (tilghman) 2009-03-02 10:42:38.000-0600

I still need a backtrace, when you report a crash.

By: Alejandro Rios P. (alerios) 2009-03-02 10:58:09.000-0600

Sorry,.. here is the backtrace:

Core was generated by `/usr/sbin/asterisk -F -g -vvv -p -g -U asterisk'.
Program terminated with signal 11, Segmentation fault.
#0  sqlite3_exec (db=0x0,
   zSql=0x83116f8 "INSERT INTO cdr (clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,start,answer,end,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield,pbx,intrunk,outtrunk,dialout) VALUES ('"..., xCallback=0, pArg=0x0, pzErrMsg=0xb5fbc1a8) at sqlite3.c:60343
60343  sqlite3_mutex_enter(db->mutex);
(gdb) backtrace
#0  sqlite3_exec (db=0x0,
   zSql=0x83116f8 "INSERT INTO cdr (clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,start,answer,end,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield,pbx,intrunk,outtrunk,dialout) VALUES ('"..., xCallback=0, pArg=0x0, pzErrMsg=0xb5fbc1a8) at sqlite3.c:60343
#1  0xb7750e9f in sqlite3_log (cdr=0x8462d38) at cdr_sqlite3_custom.c:274
#2  0x08084186 in post_cdr (cdr=0x8462d38) at cdr.c:1021
#3  0x080843a8 in ast_cdr_detach (cdr=0x8462d38) at cdr.c:1217
#4  0x0808d86b in ast_hangup (chan=0x83cfc80) at channel.c:1664
ASTERISK-1  0x080f51d8 in __ast_pbx_run (c=0x83cfc80) at pbx.c:3866
ASTERISK-2  0x080f653e in pbx_thread (data=0x83cfc80) at pbx.c:3956
ASTERISK-3  0x081306b0 in dummy_start (data=0x883c038) at utils.c:917
ASTERISK-4  0xb7c5e240 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
ASTERISK-5  0xb7d3a49e in clone () from /lib/tls/i686/cmov/libc.so.6
(gdb)

By: Digium Subversion (svnbot) 2009-03-02 11:16:58.000-0600

Repository: asterisk
Revision: 179360

U   branches/1.6.0/cdr/cdr_sqlite3_custom.c

------------------------------------------------------------------------
r179360 | tilghman | 2009-03-02 11:16:57 -0600 (Mon, 02 Mar 2009) | 4 lines

If cdr registration somehow succeeds without a config file, don't crash.
(closes issue ASTERISK-13660)
Reported by: alerios

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

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