From: csa at dside dot dyndns dot org Operating system: Gentoo Linux PHP version: 5.2.6 PHP Bug Type: PDO related Bug description: unixODBC (PDO) queries are causing segmentation error
Description: ------------ ODBC (PDO) queries are causing segmentation error on 64 bit platforms under certain conditions if unixODBC is used to provide ODBC interface. The actual problem is definition of 'pdo_odbc_column' structure (in ext/pdo_odbc/php_pdo_odbc_int.h). The 'fetched_len' member is defined 'long'. However, in odbc_stmt.c (odbc_stmt_describe) the pointer on this member is passed as argument to SQLBindCol (ODBC library) which expects pointer on SQLINTEGER instead. On 64bit platforms unixODBC defines the 'SQLINTEGER' as 'int ' (a 32 bit number) and 'long' is a 64 bit number. On x86_64 this does not cause problems while negative numbers are not used. Therefore, the bug is rarely introduces itself. Unfortunately, in the cases of NULL valued-columns it is possible what '-1' is stored in this member variable. In this case the PhP while end up with segmentation fault. I don't have access to formal ODBC specification and, therefore,don't really know if unixODBC correct in its implementation or violates specification. [ MS defines SQLINTEGER as 'long int'. But 'long int' on win64 is 32bit number. In Linux, 'long int' is 64bit and 'int' is 32bit ]. However, in either case the fix is very simple and will save php developers from lot headache. The proposed patch is available here: http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch -- Edit bug report at http://bugs.php.net/?id=45146&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45146&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45146&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45146&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45146&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45146&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45146&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45146&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45146&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45146&r=support Expected behavior: http://bugs.php.net/fix.php?id=45146&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45146&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45146&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45146&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45146&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45146&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45146&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45146&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45146&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45146&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45146&r=mysqlcfg