|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45146 unixODBC (PDO) queries are causing segmentation error
Submitted: 2008-06-01 22:22 UTC Modified: 2008-06-02 18:39 UTC
From: csa at dside dot dyndns dot org Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.6 OS: Gentoo Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: csa at dside dot dyndns dot org
New email:
PHP Version: OS:


 [2008-06-01 22:22 UTC] csa at dside dot dyndns dot org
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:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-02 18:39 UTC] csa at dside dot dyndns dot org
Things turned out to been even more complicated :( The problem is fixed in current CVS version of unixODBC.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 10:01:28 2024 UTC