[asterisk-bugs] [Asterisk 0018295]: [patch] Call to SQLDescribeCol returns an invalid ColumnSize paramenter on x64 (Patch included)
Asterisk Bug Tracker
noreply at bugs.digium.com
Wed Mar 9 23:51:39 CST 2011
A NOTE has been added to this issue.
======================================================================
https://issues.asterisk.org/view.php?id=18295
======================================================================
Reported By: pruiz
Assigned To: tilghman
======================================================================
Project: Asterisk
Issue ID: 18295
Category: Functions/func_odbc
Reproducibility: sometimes
Severity: minor
Priority: normal
Status: closed
Asterisk Version: 1.8.0
JIRA: SWP-2597
Regression: No
Reviewboard Link:
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Request Review:
Resolution: fixed
Fixed in Version:
======================================================================
Date Submitted: 2010-11-11 16:47 CST
Last Modified: 2011-03-09 23:51 CST
======================================================================
Summary: [patch] Call to SQLDescribeCol returns an invalid
ColumnSize paramenter on x64 (Patch included)
Description:
When using func_odbc with freetds odbc driver with asterisk compiled as
x86_64, the following error will appear to logs/console randomly while
making odbc calls:
[Nov 11 00:39:51] DEBUG13196: func_odbc.c:592 acf_odbc_read: Got collength
of 3 and maxcol of 1416 for column 'OP1' (offset 0)
[Nov 11 00:39:51] ERROR13196:
/usr/src/asterisk-1.8.0/include/asterisk/utils.h:513 _ast_realloc: Memory
Allocation Failure in function ast_str_make_space at line 582 of /
usr/src/asterisk-1.8.0/include/asterisk/strings.h
After debugging and tracing the error, it is related to what looks like an
internal unixODBC/freeTDS bug, by which an incorrect value gets returned as
ColumnSize when callig SQLDescribeCol function.
This ColumnSize parameter is a paremeter passed as reference (*SQLULEN),
and SQLULEN on 64bit machines corresponds to an unsigned long int (8
bytes).
However, looks like unixODBC/FreeTDS it's casting (internally) this
parameter to an *int32 before asigning the parameter's value. As such, the
function returns a value with has only updated the upper (or lower
depending on endiannes) 4 bytes of the passed SQLULEN parameter, which
makes the next call to ast_str_make_space fail as the size passed
internally to ast_realloc it's often to big to be reserved by the system.
After inspecting the code, I will report the problem to unixODBC people,
however there's a really easy fix which can be done on asterisk side to
allow this setup to work until unixODBC people fixes their problem.
To fix the issue we just need to initialize the passed parameter (maxcol)
to 0 before passing it to SQLDescribeCol. As such I'm attaching a simple
patch for it.
======================================================================
----------------------------------------------------------------------
(0132790) svnbot (reporter) - 2011-03-09 23:51
https://issues.asterisk.org/view.php?id=18295#c132790
----------------------------------------------------------------------
Repository: asterisk
Revision: 310141
_U branches/1.6.2/
U branches/1.6.2/apps/app_voicemail.c
U branches/1.6.2/funcs/func_odbc.c
U branches/1.6.2/res/res_config_odbc.c
------------------------------------------------------------------------
r310141 | tilghman | 2011-03-09 23:51:38 -0600 (Wed, 09 Mar 2011) | 12
lines
Merged revisions 310140 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r310140 | tilghman | 2011-03-09 23:38:44 -0600 (Wed, 09 Mar 2011) | 5
lines
Initialize column size to 0 to deal with a potential UnixODBC bug on
64-bit systems.
(closes issue https://issues.asterisk.org/view.php?id=18295)
Reported by: pruiz
........
------------------------------------------------------------------------
http://svn.digium.com/view/asterisk?view=rev&revision=310141
Issue History
Date Modified Username Field Change
======================================================================
2011-03-09 23:51 svnbot Note Added: 0132790
======================================================================
More information about the asterisk-bugs
mailing list