[asterisk-bugs] [Asterisk 0014286]: Crash on failure to execute SQL

Asterisk Bug Tracker noreply at bugs.digium.com
Tue Jan 20 13:38:51 CST 2009


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=14286 
====================================================================== 
Reported By:                darren1713
Assigned To:                Corydon76
====================================================================== 
Project:                    Asterisk
Issue ID:                   14286
Category:                   Resources/res_odbc
Reproducibility:            have not tried
Severity:                   minor
Priority:                   normal
Status:                     assigned
Asterisk Version:           1.4.22 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2009-01-20 12:58 CST
Last Modified:              2009-01-20 13:38 CST
====================================================================== 
Summary:                    Crash on failure to execute SQL
Description: 
* crashes when there is a SQL execute error.

I have attached a valgrind stack of the error. It is impossible to
reproduce in gdb because this error causes corrupted memory, which destroys
the stack in gdb.

In any case, the unixODBC code is very difficult to get a heads up on, but
I *think* that you cannot free the stmt if there was an error. I cannot
find any sample code to confirm this though...

Version is actually 1.4.22.1


====================================================================== 

---------------------------------------------------------------------- 
 (0098223) darren1713 (reporter) - 2009-01-20 13:38
 http://bugs.digium.com/view.php?id=14286#c98223 
---------------------------------------------------------------------- 
Actually the more I review this the more apparent the issues become. It is
almost impossible to handle the variations of sql errors that can happen in
the current code. Some invalidate the stmt, some invalidate the connection,
some do neither and there is quite a lack of error handling anywhere in the
connection/disconnection/execution process.

I suggest 2 things, which I would appreciate feedback on.

First, is since the odbc layer handles connection pooling, to create and
destroy connections on every sql statement. This will add a tiny bit of
overhead to the odbc library, but massively simplify the odbc functions in
*. The odbc library will already have pooled connections waiting for *
anyways.

The second is to re-vamp the prepare_and_execute function with something
more like http://www.unixodbc.org/doc/ProgrammerManual/Tutorial/resul.html

What do you think? 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-01-20 13:38 darren1713     Note Added: 0098223                          
======================================================================




More information about the asterisk-bugs mailing list