php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8429 erealloc() problem
Submitted: 2000-12-26 13:52 UTC Modified: 2001-03-09 21:26 UTC
From: bughuntr at ctelcom dot net Assigned:
Status: Closed Package: Class/Object related
PHP Version: 4.0.4 OS: Linux (Mandrake 7.2)
Private report: No CVE-ID: None
 [2000-12-26 13:52 UTC] bughuntr at ctelcom dot net
Under Linux, memory appears to be corrupted after Alarm object newed/ or call to DisplayObject function.  This is part of a large/complex script, around 1000 lines.

  Using BODY debugger, variables having weird stuff in them.  It is like the memory manager gets hosed.  I would be willing to give entire script/database configuration set to anyone.  The application is GPL'd.  I've got a sample database for MySQL that configures and loads as follows:
mysql <mom1create.sql
mysql <testdb.sql

the crash occurs with either of the following:
(command Line)
php mom.c

crash looks like this:
888888888888888888888888888888888888888888888888888888888888
+++++++++++++++++++<BR>walking TestActionArray<BR>+++++++++++++++++++<BR>
<BR><B>Function==CheckTestActionResult(0,0) file /home/httpd/html/mom/momact.c line 203</B><BR>
Key 0 not used<BR>
<BR><B>Function==CheckTestActionResult(Object,2) file /home/httpd/html/mom/momact.c line 203</B><BR>
key 2 for object Object
<BR>-----------------------<BR>
For Object 'ActionResult ($ARValue)':<BR>
-----------------------<BR>
new action result!<BR>
Creating New Alarm Info Object<BR>
$Alarm was NOT set<BR>
-----------------------<BR>
For Object 'ActionResult':<BR>
-----------------------<BR>
FATAL:  erealloc():  Unable to allocate 1699901065 bytes           
888888888888888888888888888888888888888888888888888888


(browser)
http://127.0.0.1/mom/mom.php


System is running 128 meg on linux.

  The objects's variables having weird stuff in them is shown in this printout:

999999999999999999999999999999999999999999999999999999999999
printout of web page:
9999999999999999999999999999999999999999999999999999999999

----->defining debug in file /home/httpd/html/mom/mom.c at line 242

Function==MonitorMachines file /home/httpd/html/mom/momact.c line 334
walking MonitoredMachineArray

Function==RunTestAction(0, 0): file /home/httpd/html/mom/momact.c line 139

Function==RunTestAction(Object, 1): file /home/httpd/html/mom/momact.c line 139

Function==RunAction(2,1) file /home/httpd/html/mom/momact.c line 71
Running PHP Command String
$ExecString="echo 'Sendmail is being Tested
';return(SUCCESS);"
Sendmail is being Tested
$Result="1"
$TestActionResult["2"]=RunAction($ActionID,$MMKey)
$ActionID = 2
-----------------------
For Object 'TesActionResult':
ServiceID -> 1
MonitoredMachineID -> 1
Result -> 1
-----------------------
+++++++++++++++++++
walking TestActionArray
+++++++++++++++++++

Function==CheckTestActionResult(0,0) file /home/httpd/html/mom/momact.c line 201
Key 0 not used

Function==CheckTestActionResult(Object,2) file /home/httpd/html/mom/momact.c line 201
key 2 for object Object 
-----------------------
For Object 'ActionResult ($ARValue)':
ServiceID -> 1
MonitoredMachineID -> 1
Result -> 1
-----------------------
new action result!
Creating New Alarm Info Object
$Alarm was NOT set
-----------------------
For Object 'ActionResult':
ServiceID -> 1
MonitoredMachineID -> ActionResult
Result -> 1
-----------------------
$ServiceID=1, $MachineID=D?  d[    
ExitNow called from 264 in file /home/httpd/html/mom/momact.c

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
function DisplayObject(&$Obj,$Name)// crash occurs even when obj //copied by not using & in front of $Obj parameter description
{
   echo "-----------------------<BR>\n"; 
   echo "For Object '$Name':<BR>\n";
           
   while ( list($key,$value) = each($Obj) )
      {  
      if (gettype($key) == "string")
         echo "$key -> $value<BR>\n";
      }      
   echo "-----------------------<BR>\n"; 
}             


function CheckTestActionResult($ARValue,$ARKey)
{
   global $MySQLConfig; // the mysql configurationinfo
   global $AlarmType;
   global $StatusType;
   global $Service;
   global $Alarm;
   global $LastActionResult;
   global $LastAlarm;     
   global $TestActionResult;

  if (defined("DEBUG"))
     print("<BR><B>Function==CheckTestActionResult($ARValue,$ARKey) file ".__FILE__." line ".__LINE__."</B><BR>\n"); 
  
  if ($ARKey == 0)
   {
   if (defined("DEBUG"))
      echo "Key 0 not used<BR>\n";
   return;                        
   }
  else
   if (defined("DEBUG"))
      echo "key $ARKey for object $ARValue\n<BR>";


  if (defined("DEBUG"))
   DisplayObject($ARValue,"ActionResult (\$ARValue)");
  
   
  $DoWork = FALSE;


   
  if (!isset($LastActionResult["$ARKey"]))
      {
      if (defined("DEBUG"))
         echo "new action result!<BR>\n";
      $DoWork = TRUE;//something has changed
      }
  else
      {
      if (defined("DEBUG"))
         echo "Check last action result<BR>\n";
      if ($ARValue->Result != $LastActionResult["$ARKey"]->Result)
         {
         $DoWork = TRUE;
         $LastActionResult["$ARKey"] = $ARValue; // save the object
         }
      }

  if ($DoWork)// only do this if something changed
   {
      if (defined("DEBUG"))
         echo "Creating New Alarm Info Object<BR>\n";
   $AlarmObj = new AlarmInfoClass;         
   // pick up the status, if it exists
   if (isset($Alarm["$ARKey"]))
      {
      if (defined("DEBUG"))
         echo "\$Alarm was set<BR>\n";
      $LastAlarm["$ARKey"] = $Alarm["$ARKey"];
      }
   else
      if (defined("DEBUG"))
         echo "\$Alarm was NOT set<BR>\n";

   DisplayObject($ARValue,"ActionResult");


   $MachineID = $ARValue->MonitoredMachineID;
   $ServiceID = $ARValue->ServiceID;

   if (defined("DEBUG"))
      echo "\$ServiceID=$ServiceID, \$MachineID=$MachineID<BR>\n";

 ExitNow(__LINE__,__FILE__);

   if ($ARValue->Result == FAIL)
      {
      $ID = $Service["$ServiceID"]->FKStatusIDDefaultFail ;
      $AlarmObj->Type = FAIL;
      $AlarmObj->AlarmState = $Service["$ServiceID"]->FKAlarmIDDefaultFail;
      }
   else
      {
      $ID = $Service["$ServiceID"]->FKStatusIDDefaultSucceed ;
      $AlarmObj->Type = SUCCESS;  
      if(defined("DEBUG"))
         DisplayObject($Service["$ServiceID"],"Service");
      $AlarmObj->AlarmState = $Service["$ServiceID"]->FKAlarmIDDefaultsucceed;
      }

   $AlarmObj->Status = $ID ; 
   $AlarmObj->MachineID = $MachineID;
   $AlarmObj->New = TRUE; // indicate this is a new set
   $AlarmObj->ID = 0; // not yet stored in database
   $AlarmObj->ServiceID = $ServiceID;   
   $Alarm["$ARKey"]= $AlarmObj;
   unset($AlarmObj); // force freeing of memory
   }

}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-08 14:01 UTC] stas@php.net
Could you produce minimal PHP code that reproduces the
problem? 1000 lines of DB-dependant application is pretty
hard to investigate. Also, do you have some non-standard PHP
modules in your application?
 [2001-02-04 13:07 UTC] sniper@php.net
Please include a gdb backtrace of the crash into this bug report.
Instructions can be found here:
http://bugs.php.net/bugs-generating-backtrace.php

Also, please include a SHORT script which can (without
any DB's or such) used to reproduce the crash.

--Jani

 [2001-03-09 21:26 UTC] sniper@php.net
No feedback. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 17:01:30 2024 UTC