[Home]

Summary:ASTERISK-12577: Asterisk crashes, leaving a voicemail message stored on pgsql DB via ODBC
Reporter:Mike Oliveras (moliveras)Labels:
Date Opened:2008-08-13 12:32:27Date Closed:2011-06-07 14:00:20
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Applications/app_voicemail/ODBC
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) gdb-optimized.txt
( 1) valgrind.txt
Description:I compiled asterisk 2.4.21.1 for ODBC voicemail using a PGSQL DB. Every time I left a voicemail message, asterisk would get a segmentation fault and restart.  

I also tried this with the 1.4 branch and got the same result (branch1.4-r137188).

The odd thing is that after compiling a NON OPTIMIZED build to get a backtrace the crash no longer occurs.  I left over 150 messages with the non optimized build and saw no problems.  Using the OPTIMIZED build crashes asterisk ever time after the first voicemail message is left.  I will attach the OPTIMIZED backtrace as that was all I could get.  Let me know what additional data you would like to see and I will also attach it.

Best Regards,

Mike Oliveras

Comments:By: Tilghman Lesher (tilghman) 2008-08-14 12:16:41

If the crash occurs consistently with optimizations on, but not with optimizations off, then you have discovered a bug in gcc or whatever compiler you're using.  If possible, try using a different compiler version.  You may want to report this issue to your operating system vendor, if they packaged the compiler that you're using.

By: Tilghman Lesher (tilghman) 2008-08-14 12:18:24

Since this is related to a memory error, you may want to run this under valgrind, as specified in doc/valgrind.txt.  Please note that even if Asterisk does not crash under valgrind, the output gathered there may still be useful to us.

By: Mike Oliveras (moliveras) 2008-08-15 07:32:31

[root@mikeo_asterisk1 ~]# gcc -v
Using built-in specs.

I am using centOS 5.1, and have the latest version of gcc avaliable
gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)

I ran asterisk under valgrind as requested - asterisk did not crash in this case.
valgrind --log-file-exactly=valgrind.txt asterisk -vvvvcg 2>malloc_debug.txt

The malloc_debug file was empty so I am just attaching the valgrind.txt file.



By: Tilghman Lesher (tilghman) 2008-08-15 09:00:19

The results of this valgrind output suggests that there was no memory error condition detected.  The key to this is noting that other than the dlopen errors and the invalid fd errors, no other exceptional memory conditions were detected.  The one I would have expected is an "invalid write".

By: Tilghman Lesher (tilghman) 2008-08-15 09:03:12

Since this error occurs so deep within the psqlodbc library, the next step would be download the latest version of psqlodbc from the PgSQL website and compiling from source.  Please note that a distribution version of psqlodbc rarely includes the latest release of psqlodbc.  Additionally, you may have to alter your odbcinst.ini, since the source of psqlodbc will by default install to /usr/local, instead of /usr, as packaged versions tend to.

By: Mike Oliveras (moliveras) 2008-08-20 23:38:21

It seems that the driver in the /etc/odbcinst.ini file is specifying the unixODBC driver.  I changed this to use the postgresql-odbc driver and the crashes are no longer occurring.

Below is step 3 from voicemail_odbc_postgresql.txt

3) Make sure you have the PostgreSQL odbc driver setup in /etc/odbcinst.ini.
Mine looks like:

[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/lib/libodbcpsql.so
Setup           = /usr/lib/libodbcpsqlS.so
FileUsage       = 1

I no longer get the crashes once I changed the Driver to:
Driver  =  /usr/lib/psqlodbc.so

I did notice that I get an error message using 1.4.21.1 but not with the SVN version of the 1.4 branch.

 == Parsing '/var/spool/asterisk/voicemail/cust1/100/INBOX/msg0000.txt': Length is 6950
Found
mikeo_asterisk1*CLI> [Aug 21 00:42:23] WARNING[11536]: app_voicemail.c:1131 retrieve_file: SQL Get Data error!
[SELECT * FROM voicemessages WHERE dir=? AND msgnum=?]

[Aug 21 00:42:23] WARNING[11536]: app_voicemail.c:1131 retrieve_file: SQL Get Data error!
[SELECT * FROM voicemessages WHERE dir=? AND msgnum=?]



It does seem to be working as expected however

By: Tilghman Lesher (tilghman) 2008-08-21 09:38:44

The exact name is going to depend upon how your distribution packages files.  In any case, since getting a new version of the library fixed this, I'm going to close this issue.