Bug #42765 [Opn]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)

From: Date: Fri, 05 Jun 2015 20:43:30 +0000
Subject: Bug #42765 [Opn]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193159@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=42765&edit=1 ID: 42765 Updated by: cmb@php.net Reported by: sms at inbox dot ru Summary: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error) Status: Open Type: Bug Package: PDO ODBC Operating System: Windows 2000 SP4 PHP Version: 5.2.4 Block user comment: N Private report: N New Comment: It appears that csa is right. Unfortunately, the patch isn't available anymore. Anyhow, I see two potential problems with the relevant code[1]. The first is that displaysize is not initialized, but the MSDN documentation[2] states: | Please note that some drivers may only write the lower 32-bit or | 16-bit of a buffer and leave the higher-order bit unchanged. | Therefore, applications should initialize the value to 0 before | calling this function. The second is that displaysize (signed) is assigned to colsize (unsigned). However, the MSDN documentation[3] states: | If the driver cannot determine the column or parameter length of | variable types, it returns SQL_NO_TOTAL. SQL_NO_TOTAL is defined to be -4. [1] <https://github.com/php/php-src/blob/php-5.6.9/ext/pdo_odbc/odbc_stmt.c#L568-L578> [2] <https://msdn.microsoft.com/en-us/library/ms713558(v=vs.85).aspx> [3] <https://msdn.microsoft.com/en-us/library/ms713974(v=vs.85).aspx> Previous Comments: ------------------------------------------------------------------------ [2015-06-05 17:37:54] cmb@php.net > SqlSrv, the official driver from Microsoft, does only support > PHP up to 5.4 and it looks like there won't be any update in the > near future too. The drivers are actively maintained (again?): <https://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx>. ------------------------------------------------------------------------ [2014-10-06 15:58:19] joachim dot havloujian at fauser dot ag I am getting the exact same error when fetching a long binary field from a Microsoft SQL Server. The problem is that I rely on a PHP extension which supports MSSQL and the latest PHP build. Besides ODBC there are none which are fully working with the newest PHP version. The extension PHP_MSSQL isn't stated as deprecated but there is no official update. SqlSrv, the official driver from Microsoft, does only support PHP up to 5.4 and it looks like there won't be any update in the near future too. That's why me and my coworkers would appreciate if this bug will be fixed soon. Best regards. ------------------------------------------------------------------------ [2011-08-30 13:07:12] andreas at codejungle dot org Bug is still existing in PHP 5.3.5 (os ubuntu natty) The chunk workaround from skettler is working, but 22 000 queries for a 40 MB file is not optimal. I tried also the php-ds-odbc_blob.patch, and the "Out of memory" error was gone, but for some reasons, now the files are twice as large :( ------------------------------------------------------------------------ [2010-06-20 17:43:42] pajoye@php.net hm, I don't maintain odbc. However I would suggest SqlServer users on Windows to use SqlSrv instead, much more stable and features complete. ------------------------------------------------------------------------ [2009-04-29 10:44:33] skettler@php.net Confirmed not fixed with latest PHP 5.2 snapshot VC6 x86 Thread Safe (2009-Apr-27 00:00:00): Fatal error: Out of memory (allocated 262144) (tried to allocate 4294967295 bytes) Current workaround is getting the length of the image, retrieving chunks of 4096 characters and putting them back together in PHP. SQL-Queries for this workaround look like these: SELECT DATALENGTH(imagefield) AS imagelength FROM imagetable WHERE imageid = ? SELECT CAST(SUBSTRING(imagefield, offset, length) AS VARCHAR(4096)) AS imagechunk FROM imagetable WHERE imageid = ? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=42765 -- Edit this bug report at https://bugs.php.net/bug.php?id=42765&edit=1

« previous php.bugs (#193159) next »