ID:               45146
 User updated by:  csa at dside dot dyndns dot org
 Reported By:      csa at dside dot dyndns dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         PDO related
 Operating System: Gentoo Linux
 PHP Version:      5.2.6
 New Comment:

Things turned out to been even more complicated :( The problem is fixed
in current CVS version of unixODBC.


Previous Comments:
------------------------------------------------------------------------

[2008-06-01 22:22:58] csa at dside dot dyndns dot org

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 this bug report at http://bugs.php.net/?id=45146&edit=1

Reply via email to