php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68964 Allowed memory size exhausted with odbc_exec
Submitted: 2015-01-31 18:38 UTC Modified: 2015-03-16 07:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: giodev at panozzo dot it Assigned: ab (profile)
Status: Closed Package: ODBC related
PHP Version: 5.6.5 OS: Windows Server 2012
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: giodev at panozzo dot it
New email:
PHP Version: OS:

 

 [2015-01-31 18:38 UTC] giodev at panozzo dot it
Description:
------------
I'm running PHP 5.6.5 x64 nts on Windows Server 2012, 64bit, fastcgi.

When I execute odbc_exec from a table with ntext field, selecting the ntext field, PHP crashes my script with the following error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate
 1073741824 bytes) in C:\Users\username1\Desktop\odbc_exec_crash_test.php on line 16

The same problem persists with almost all previous versions available on the download site, both 32 and 64 bits, non-thread-safe:
 php 5.6.5 i386 nts
 php 5.5.21 x64 nts
 php 5.4.37 i386 nts


Test script:
---------------
<?php
	$dbloc_dsn_srv = "DRIVER={SQL Server Native Client 11.0};Server=MYSERVER\MYINSTANCE".
		";ExtendedAnsiSQL=1;Database=mydb;UID=userweb1;PWD=pwdweb";
	$cn = odbc_pconnect($dbloc_dsn_srv,"","")
			or die("Error connecting to DB\n".odbc_errormsg());
			
	print "PHP version ".phpversion()."\n";
	
	$qry = "IF OBJECT_ID('test1', 'U') IS NOT NULL DROP TABLE test1";
	$res = odbc_exec($cn,$qry) or die("Drop query error: $qry\n");
	
	$qry = "CREATE TABLE test1 ( id integer not null, field ntext default '' not null, primary key(id))";
	$res = odbc_exec($cn,$qry) or die("Query error: $qry\n");
	
	$qry = "SELECT field from test1";
	$res = odbc_exec($cn,$qry) or die("Query error: $qry\n");
	while( $row = odbc_fetch_object($res) ) {
		print $row->field."\n";
	}

	print "Done without errors\n";
?>


Expected result:
----------------
PHP version 5.6.5

Done without errors


Actual result:
--------------
PHP version 5.6.5

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1073741824 bytes) in C:\Users\username1\Desktop\odbc_exec_crash_test.php on line 16


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-31 18:52 UTC] giodev at panozzo dot it
Two more notes:
- This happens when querying both MSSQL server Express 2008 or 2012
- Workaround: change ntext field to nvarchar(max) (as explained here: https://msdn.microsoft.com/en-us/library/ms186939.aspx)
 [2015-02-03 16:26 UTC] giodev at panozzo dot it
Update: nxtext and nvrchar(max) fields causes the problem, even if they are empty. If you change the fields to nvarchar(4000), all seems to be working.

This bug is similar to bug #67437, but #67437 is linux related.
 [2015-02-06 18:06 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a41aa46759d20e23af92df00b917ca66c6102412
Log: Fixed bug #68964 Allowed memory size exhausted with odbc_exec
 [2015-02-06 18:06 UTC] ab@php.net
-Status: Open +Status: Closed
 [2015-02-06 18:10 UTC] ab@php.net
-Assigned To: +Assigned To: ab
 [2015-02-06 18:10 UTC] ab@php.net
@giodev, please check any snapshot starting with rev a41aa46.

Thanks.
 [2015-03-16 05:44 UTC] xaionaro at gmail dot com
The bug is still there in PHP-5.6.6

[16-Mar-2015 08:40:10] WARNING: [pool www] child 63955 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 4294967293 bytes) in /var/www/stpdn.ut.mephi.ru/root/main.php on line 950"

# php --version
PHP 5.6.6-2 (cli) (built: Feb 24 2015 10:07:30) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
 [2015-03-16 07:22 UTC] ab@php.net
Hey @xaionaro,

please check a snapshot towards the commit I've asked. Or in the meantime, this fix can be noticeable in the latest RCs.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC