[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
Thu Mar 10 00:49:03 CST 2011
The following issue has been set as RELATED TO issue 0017330.
======================================================================
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-10 00:49 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.
======================================================================
Relationships ID Summary
----------------------------------------------------------------------
related to 0017330 Asterisk crash on ODBC /usr/lib/libodbc...
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2011-03-10 00:49 tilghman Relationship added related to 0017330
======================================================================
More information about the asterisk-bugs
mailing list