|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22911 Setting odbc.defaultlrl = 0 results in FATAL: emalloc(): Unable to allocate
Submitted: 2003-03-26 16:18 UTC Modified: 2003-08-01 06:10 UTC
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: wbarnett at ncta dot com Assigned:
Status: No Feedback Package: ODBC related
PHP Version: 4.3.2RC1 OS: Windows 2000
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: wbarnett at ncta dot com
New email:
PHP Version: OS:


 [2003-03-26 16:18 UTC] wbarnett at ncta dot com

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

FATAL:  emalloc():  Unable to allocate 2012964085 bytes

Note that setting the Setting odbc.defaultlrl = 131072 (as high as I needed to go methinks) works just fine.

Cant get a GDB Backtrace.

Script that generates:


function ODBCConnect(){
	global $DBName;
	global $DBUser;
	global $DBPass;
	$cnx=odbc_connect($DBName, $DBUser, $DBPass);
	return $cnx;
function GenerateMainTable(){
	$strSQL="SELECT MailID, MailName, MailDate FROM sysMail";
	if (isset($_GET['SortOrder'])){
		$strSQL.=" ORDER BY $SortOrder";
	$cur=odbc_exec($cnx, $strSQL);
	$TableDef="<td class=\"Main\">";
	while (odbc_fetch_row($cur)){
		$MailID=odbc_result($cur, "MailID");
		$MailName=odbc_result($cur, "MailName");
		$MailDate=date('m.d.y', strtotime(odbc_result($cur, "MailDate")));
		echo "<tr>$TableDef<center><a href=\"MailDetail.php?MailID=$MailID\">$MailID</center></td>$TableDef $MailName </td>$TableDef<center>$MailDate</center></td></tr>";



Data it is pulling is pretty simple--an integer ID, a string for name and a date value.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-18 22:32 UTC]
Can you tell me if this is with SQL Server, and which MDAC is being used?  
 [2003-05-18 23:07 UTC] wbarnett at ncta dot com
Not with SQL server, although I can test there too. It happened with an Access DB I was using for development purposes.

 [2003-07-24 14:12 UTC] m dot tschursch at ic3s dot de
hit exactly the same problem while trying to connect to MSSQL Server !
my software:
PHP: php 4.3.2 
unixODBC: 2.2.5
freeTDS: 0.6.1 
on Linux 

the problem was, that the result-struct was reused 
for all queries i send to db ... so i didnt run into
any problem, till the next querie had more or same count
of columns, but it crashed as i tried to fetch data 
for a 3-column query right after i executed a 
18-column query. doh.

hunted it till i found a solution:
in ext/odbc/php_odbc.c i added a line in function
PHP_FUNCTION(odbc_execute) {
  	/* Close cursor, needed for doing multiple selects */
	rc = SQLFreeStmt(result->stmt, SQL_CLOSE);

	if (rc == SQL_ERROR) {
	  odbc_sql_error(result->conn_ptr, result->stmt, "SQLFreeStmt");	
	rc = SQLExecute(result->stmt);
// IMPORTANT !! driver dont seems to set numcols here .. 
        result->numcols = 0; 

perhaps this should be done in SQLFreeStmt ... 
i dont know exactly 

finaly this works for me ... perhaps this can help you
 [2003-07-26 12:28 UTC]
Well, that sounds like an easy enough fix, thanks m.tschursch!  wbarnett can you please try the source patch suggested below and tell me if this fixes your problem?

If you cannot compile PHP please let me know and I'll see if I can get you a snapshot with it built-in.  
 [2003-08-01 06:10 UTC]
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 "Open". Thank you.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Feb 24 10:01:27 2024 UTC