php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75013 Fatal error: Allowed memory size
Submitted: 2017-07-31 21:59 UTC Modified: 2022-01-30 04:22 UTC
Votes:14
Avg. Score:4.8 ± 0.6
Reproduced:12 of 12 (100.0%)
Same Version:8 (66.7%)
Same OS:6 (50.0%)
From: ymtene at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: ODBC related
PHP Version: 7.1.7 OS: CentOS Linux 7.2.1511 (Core)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ymtene at gmail dot com
New email:
PHP Version: OS:

 

 [2017-07-31 21:59 UTC] ymtene at gmail dot com
Description:
------------
I have problems executing a sql statement from php7 to a db2 database, here are my configuration data and error:

PHP version:
PHP 7.1.7 (cli) (built: Jul  6 2017 12:10:28) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.7, Copyright (c) 1999-2017, by Zend Technologies

UNIXODBC version:
unixODBC-2.3.1-11.el7.x86_64

iSeriessAccess version:
iSeriesAccess-7.1.0-1.0.x86_64

ERROR:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 140325171494924 bytes) in /var/www/html/test.php on line 19

I try set more memory on php.ini but not work.
Also, I try with set ini_set('memory_limit', '-1'); and dont work.

What can I do to make it work? Any suggestion? I have the same installation in php5.4 and it works perfect, but now I need run it on php7.

---
From manual page: http://www.php.net/index
---


Test script:
---------------
<?php
//Datos para conexión a db2//
$as_username="username";
$as_password="passwd";
$bd = "ANYDB";
$as_dsn ="DRIVER=iSeries Access ODBC Driver 64-bit;SYSTEM=x.x.x.x;DBQ=$bd";
$as_conn = odbc_connect ($as_dsn, $as_username, $as_password);
if (!$as_conn) {
   echo "No existe conexión a la base de datos."; // Error message
}else{
  $cadena_sql= "SELECT CAMPO FROM $db.TABLA";
  $result = odbc_exec($as_conn,$cadena_sql);  //Problem to execute
if ($persona=odbc_fetch_array($result,'')){
  ...
}else{
  ...
  }
}
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-31 22:35 UTC] spam2 at rhsoft dot net
when you get that error your value of -1 is not accepted

php_admin_flag/php_admin_value in any config can't be changed with ini_set() by intention and when you edit php.ini you pretty sure overlook some vhost specific config

the reaosn why you get it with PHP7 is that the stuff allocating mekory previously did not use then Zend memory manager and never was affected by the limits and now that bug is fixed
 [2017-08-02 17:27 UTC] cmb@php.net
> the reaosn why you get it with PHP7 is that the stuff allocating
> mekory previously did not use then Zend memory manager and never
> was affected by the limits and now that bug is fixed

> (tried to allocate 140325171494924 bytes)

That would be 140TB!
 [2017-08-15 15:18 UTC] jeroen at vdmi dot nl
This issue also happens to me, but I happen to connect to an MDB (Access) database.

PHP version:
PHP 7.1.4 (cli) (built: Apr 25 2017 03:23:01) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
    with Zend OPcache v7.1.4, Copyright (c) 1999-2017, by Zend Technologies

Other versions
libodbc1: 2.3.1-3
unixodbc: 2.3.1-3
unixodbc-dev: 2.3.1-3
libmdbodbc1: 0.7.1-2

I'm able to reproduce it with the following MDB (both tables in it):
http://www.rogersaccesslibrary.com/download3.asp?SampleName=Books.mdb

Error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 139968689209376 bytes

It might have to do with some field type though. I am able to read some of my tables. I have one table in my MDB with just 2 text columns and that one reads fine.
 [2017-08-15 15:22 UTC] jeroen at vdmi dot nl
Relevant test code:

<?php
$connection = odbc_connect("Driver=MDBTools;DBQ=/var/www/accessdb/Books_be.mdb", '', '');
$result = odbc_exec($connection, "SELECT * FROM Authors");

while (odbc_fetch_row($result)) {
  for ($i = 1; $i <= odbc_num_fields($result); $i++) {
    echo "Result is " . odbc_result($result, $i);
  }
}
 [2017-11-11 17:00 UTC] giany at x83 dot org
Hi,
Any update regarding this issue?
Any workaround?
 [2018-11-27 10:44 UTC] marcel dot utz at uniklinik-freiburg dot de
Dear all,

same issue on SLE 12.3, PHP 7.2, Driver: libmdbodbc.so.1, MS Access Database. When odbc_exec($connection, "SELECT id FROM table"), I got an error "Allowed memory size of 2097152 bytes exhausted (tried to allocate 140 Tbytes)". When trying via "isql" in command line with same driver I got data from database.

Is there still any solution for this issue?

Would be nice to get some response!

Thank you and best!
 [2020-10-05 09:11 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-10-05 09:11 UTC] cmb@php.net
The relevant test code provided by jeroen at vdmi dot nl work fine
for me with the Microsoft Access Driver (Windows).  If anybody can
still reproduce this with any of the actively supported PHP
versions[1], please provide a minimal self-contained reproduce
script, and an ODBC trace of running that script.

[1] <https://www.php.net/supported-versions.php>
 [2020-10-18 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2020-12-15 18:02 UTC] jon at donnasaxby dot com
I am getting this problem with php 7.2 x64 running on Windows 2016
My SQL should return a short string (a UUID), but it crashes after demanding several terabytes of memory.
Allowed memory size of 2147483648 bytes exhausted (tried to allocate 2074469204224 bytes) 
I can test the SQL call directly via an IDE, and it is correct and definitely returns just a UUID.
 [2020-12-15 18:22 UTC] cmb@php.net
Jon, please provide a minimal reproduce script, and an ODBC trace.
Also note that we do no longer support PHP 7.2, and that even PHP
7.3 won't receive bug fixes anymore.
 [2022-01-18 15:37 UTC] darwincabaro at gmail dot com
Hi! i have same problem

ODBC 64 BITS

PHP 7.3

the error occurs when I use prepare and execute


$conn = odbc_connect("Driver={IBM INFORMIX ODBC DRIVER (64-bit)};
    Server=SERVERNAME; Database=MYDB;","userdb", "pwdhash");
      if (!($conn)) {
        echo "<p>Connection to DB via ODBC failed: ";
        echo odbc_errormsg ($conn );
        echo "</p>\n";
      }

      $sql = "SELECT FIRST 1 * FROM test";
      $rs = odbc_exec($conn,$sql); //problem here

      odbc_result_all($rs);
 [2022-01-18 15:50 UTC] cmb@php.net
-Status: No Feedback +Status: Feedback
 [2022-01-18 15:50 UTC] cmb@php.net
> PHP 7.3

We do no longer support PHP 7.3.  Does it also happen with any of
the actively supported PHP versions[1]?  If so, please provide an
ODBC trace of the given script.

[1] <https://www.php.net/supported-versions.php>
 [2022-01-18 16:28 UTC] darwincabaro at gmail dot com
Hello again, i am using xampp, php 7.4

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 2731599200272 bytes) in C:\xampp\htdocs\test.php on line 11

$conn = odbc_connect("Driver={IBM INFORMIX ODBC DRIVER (64-bit)};
Server=nameserver; Database=namedb;","userdb", "pwddb") or exit('Cannot open with dns.');
if (!$conn) {
    exit("Connection Failed: " . $conn);
}

$sql = 'SELECT FIRST 1 * FROM test;';
$rs = odbc_exec($conn, $sql); //Fatal error:
if (!$rs) {
    exit("Error in SQL");
}

odbc_result_all($rs);
 [2022-01-18 17:03 UTC] cmb@php.net
We do no longer actively support PHP-7.4, either, but at the very
least I need an ODBC trace, since I don't have an Informix DB
setup.
 [2022-01-30 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC