[unixODBC-support] Segfault in libodbccr.so on x86_64

Colin Snover unixodbc.org at zetafleet.com
Sat Dec 22 11:14:50 GMT 2007

Hello all,

I am experiencing a problem with unixODBC nearly identical to the
problem sent to the list in mid-November by Cherie Soleil ("core dump in
libodbccr.so on HP iA64"). I am running on x86_64 rather than IA64, but
the problem seems to occur at the same place in the code. Here is the
full stack trace:

#0  0x00002b29d319d01c in memcpy () from /lib/libc.so.6
#1  0x00002b29dc8c8e73 in fetch_row (cl_statement=0xe36b00,
row_number=0, offset=0) at SQLExtendedFetch.c:277
#2  0x00002b29dc8c91b1 in fetch_rowset (cl_statement=0xe36b00,
rows_in_set=1, row_offset=0, fetched_rows=0x7fffda28eb04,
row_status_array=0x0, rows_fetched_ptr=0x0)
    at SQLExtendedFetch.c:464
#3  0x00002b29dc8c93e7 in do_fetch_scroll (cl_statement=0xe36b00,
fetch_orientation=1, fetch_offset=0, row_status_ptr=0xe3fb20,
rows_fetched_ptr=0x0, ext_fetch=0)
    at SQLExtendedFetch.c:749
#4  0x00002b29dc8c9a04 in CLFetchScroll (statement_handle=0xe36b00,
fetch_orientation=1, fetch_offset=0) at SQLFetchScroll.c:98
#5  0x00002b29d9c3dcd6 in SQLFetchScroll (statement_handle=0xe3e2b0,
fetch_orientation=1, fetch_offset=0) at SQLFetchScroll.c:270
#6  0x00002b29da71716a in odbc_stmt_fetch (stmt=0xdcffa8, ori=<value
optimized out>, offset=6) at
#7  0x00002b29d9e9b173 in ?? () from /usr/lib/php5/20060613/pdo.so
#8  0x00002b29d9e9b364 in ?? () from /usr/lib/php5/20060613/pdo.so
#9  0x00002b29d9e9c44b in ?? () from /usr/lib/php5/20060613/pdo.so
#10 0x0000000000676642 in ?? ()
#11 0x0000000000666cac in execute ()
#12 0x0000000000647cd3 in zend_execute_scripts ()
#13 0x0000000000606288 in php_execute_script ()
#14 0x00000000006d0960 in main ()

As you can probably tell from the paths in the backtrace, I'm trying to
use unixODBC via the PHP PDO_ODBC extension. The database being used is
a MSSQL database, with unixODBC configured to use the FreeTDS ODBC
driver. The script used to trigger this problem is very basic:

$pdo = new PDO('odbc:dbname', 'username', 'password');
$stmt = $pdo->query('exec sp_columns @table_name = "Audio"');

Any time a fetch is performed, a segfault occurs, so this could be made
into an even simpler testcase.

I tried downloading and compiling unixODBC-2.2.13pre from the FTP
server, but there was a compilation failure (presumably due to a missing
diaginternal.h file). For fun, here's the compile error:

-DHAVE_STRCHR=1 -DUNIXODBC_SOURCE=1 -I. -I. -I../include -g -O2
-DENABLE_INI_CACHING -pthread -MT diag.lo -MD -MP -MF .deps/diag.Tpo -c
diag.c  -fPIC -DPIC -o .libs/diag.o
diag.c:10:26: error: diaginternal.h: No such file or directory
diag.c:12: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:18: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'g_aDiagStates'
diag.c:140: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagAlloc'
diag.c:161: error: expected ')' before 'h'
diag.c:171: error: expected ')' before 'h'
diag.c:189: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagPush'
diag.c:220: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagPeek'
diag.c:230: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagPop'
diag.c:250: error: expected ')' before 'h'
diag.c:260: error: expected ')' before 'h'
diag.c:271: error: expected ')' before 'h'
diag.c:281: error: expected ')' before 'h'
diag.c:291: error: expected ')' before 'h'
diag.c:301: error: expected ')' before 'h'
diag.c:312: error: expected ')' before 'h'
diag.c:323: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagGetCursorRowCount'
diag.c:333: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:343: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagGetDyanmicFunctionCode'
diag.c:353: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagGetNumber'
diag.c:363: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagGetReturnCode'
diag.c:373: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagGetRowCount'
diag.c:383: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:393: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:403: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagRecordAlloc'
diag.c:437: error: expected ')' before 'h'
diag.c:449: error: expected ')' before 'h'
diag.c:459: error: expected ')' before 'h'
diag.c:487: error: expected ')' before 'h'
diag.c:497: error: expected ')' before 'h'
diag.c:507: error: expected ')' before 'h'
diag.c:517: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:527: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagRecordGetColumnNumber'
diag.c:537: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:547: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:561: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagRecordGetNative'
diag.c:571: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'diagRecordGetRowNumber'
diag.c:581: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:591: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
diag.c:601: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
make[1]: *** [diag.lo] Error 1
make[1]: Leaving directory

The first step, I guess, would be to get that source package updated on
FTP with diaginternal.h to see if it resolves the problem, then move on
from there if it doesn't.

Thanks for your help!


Colin Snover

More information about the unixODBC-support mailing list