[PHP-DEV] PHP 4.0 Bug #9486 Updated: seems to be memory related

2001-02-27 Thread derick

ID: 9486
Updated by: derick
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Feedback
Bug Type: Reproduceable crash
Assigned To: 
Comments:

Can you possible reproduce it with a script that does not use databases? It's kinda 
hard to reproduce this way for us.

Previous Comments:
---

[2001-02-27 15:16:25] [EMAIL PROTECTED]
?php

#  Hi:
#
#  Running PHP 4.0.5-dev Feb 20 2001
#  Windows NT 4.0 SP 6a
#  Apache 1.3.6
#  MySQL 3.23.32
#
#  The problem does not exist in 4.0.4-dev Nov 23 2000.
#
#  Problem arises when doing an isset() on a
#  a multidimensional array inside a function
#  that has that variable as an optional argument
#  but the argument hasn't been set, so it
#  defaults to ''.
#
#  But, it's not that simple.  Problem comes
#  and goes depending on how much memory is
#  being used.
#
#  Also, situation is only happening when
#  using results from mysql_field_name().
#
#  In addition, sometimes the page gets
#  created by PHP and sent to the browser,
#  but PHP crashes anyway.
#
#  I've already spent six hours trying to
#  pinpoint what's going on, though haven't
#  been able to hit the nail on the head yet.
#
#  Good luck.
#
#  --Dan


class Test {

   var $H = 'localhost';
   var $U = 'track';
   var $P = 'flight9';
   var $D = 'SessionTracker';


   function Setup() {
  $this-C = @mysql_connect("$this-H", "$this-U", "$this-P");
  $this-Hand = @mysql_select_db("$this-D", $this-C);
  $this-Res = @mysql_query("$this-Query",$this-C);
  $this-Cols = @mysql_num_fields($this-Res);
   }


   function FieldName($FileName,$FileLine,$ColNum) {
  if ( $Output = @mysql_field_name($this-Res, $ColNum) ) {
 return $Output;
  } else {
 echo "Field Name Had Problem";
  }
   }


   #  BEGIN ALTERNATIVE TEST FUNCTIONS HERE...

   # Uses MySQL data, but doesn't have the "$Col" argument.
   function Good() {
  for ($Count = 0; $Count  $this-Cols; $Count++) {
 $FieldNames[] = $this-FieldName('test','here', $Count);
 if ( !isset($Col[$FieldNames[$Count]]['hide']) ) {
$VisibleFields++;
echo "$Count = $FieldNames[$Count]. ";
 }
  }
   }


   # Doesn't use MySQL data, but uses "$Col" argument.
   function NoProblem($Col='') {
  for ($Count = 0; $Count  3; $Count++) {
 $FieldNames[] = 'dog';
 $FieldNames[] = 'somename';
 $FieldNames[] = 'cat';
 if ( !isset($Col[$FieldNames[$Count]]['hide']) ) {
$VisibleFields++;
echo "$Count = $FieldNames[$Count]. ";
 }
  }

   }


   # This is the function which causes the problems.
   # Uses MySQL data and has a "$Col" argument.
   function Bad($Col='') {
  for ($Count = 0; $Count  $this-Cols; $Count++) {

 #
 #  "Field Name Call -- Short"
 #
  $FieldNames[] = $this-FieldName('test','here', $Count);

 #
 #  "Field Name Call -- Long"
 #
 # $FieldNames[] = $this-FieldName("FieldName() had error when RSATbl() was 
called by $FileName","$FileLine", $Count);

 #  PROBLEM HAPPENS ON NEXT LINE
 #  Commenting it and the closing } gets the
 #  problems to stop.
 if ( !isset($Col[$FieldNames[$Count]]['hide']) ) {

# Commenting out the following line
# completely shifts the pattern of what
# is okay, crashes and infinite loops!
 $VisibleFields++;

echo "$Count = $FieldNames[$Count]. ";
 }

  }# End of for $Count
   }# End of Bad()
}# End of class


$SQL = new Test;



# TEST SCENARIOS FOR RUNNING THE BAD() FUNCTION


# WHEN:---
#   "Field Name Call -- Short"
#   "$VisibleFields++;" is open
#
# Okay if 1 or 2 Columns:
#   $SQL-Query = "SELECT concat('hi') as H";
#   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B";
# Infinite Loop if 3 Columns:
#   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B, concat('why') as W";
# Crashes if 4 Columns:
   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B, concat('why') as W, 
concat('oh') as O";


# WHEN:---
#   "Field Name Call -- Long"
#   "$VisibleFields++;" is open
#
# Okay if 1 Column:
#   $SQL-Query = "SELECT concat('hi') as H";
# Infinite Loop if 2 Columns:
#   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B";
# Crash if 3 or more Columns:
#   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B, concat('why') as W";
#   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B, concat('why') as W, 
concat('oh') as O";


# WHEN:---
#   "Field Name Call -- 

[PHP-DEV] PHP 4.0 Bug #9486 Updated: seems to be memory related

2001-02-27 Thread danielc

ID: 9486
User Update by: [EMAIL PROTECTED]
Old-Status: Feedback
Status: Open
Bug Type: Reproduceable crash
Description: seems to be memory related

I took the ease of your being able to run the tests via database into account.  The 
queries don't call any fields.  They just call the concat() function.  All you need to 
do with the database is put in host, user, pass, and name of a valid database.

I haven't been able to reproduce it w/o the databse connection.

Previous Comments:
---

[2001-02-27 15:39:18] [EMAIL PROTECTED]
Can you possible reproduce it with a script that does not use databases? It's kinda 
hard to reproduce this way for us.

---

[2001-02-27 15:16:25] [EMAIL PROTECTED]
?php

#  Hi:
#
#  Running PHP 4.0.5-dev Feb 20 2001
#  Windows NT 4.0 SP 6a
#  Apache 1.3.6
#  MySQL 3.23.32
#
#  The problem does not exist in 4.0.4-dev Nov 23 2000.
#
#  Problem arises when doing an isset() on a
#  a multidimensional array inside a function
#  that has that variable as an optional argument
#  but the argument hasn't been set, so it
#  defaults to ''.
#
#  But, it's not that simple.  Problem comes
#  and goes depending on how much memory is
#  being used.
#
#  Also, situation is only happening when
#  using results from mysql_field_name().
#
#  In addition, sometimes the page gets
#  created by PHP and sent to the browser,
#  but PHP crashes anyway.
#
#  I've already spent six hours trying to
#  pinpoint what's going on, though haven't
#  been able to hit the nail on the head yet.
#
#  Good luck.
#
#  --Dan


class Test {

   var $H = 'localhost';
   var $U = 'track';
   var $P = 'flight9';
   var $D = 'SessionTracker';


   function Setup() {
  $this-C = @mysql_connect("$this-H", "$this-U", "$this-P");
  $this-Hand = @mysql_select_db("$this-D", $this-C);
  $this-Res = @mysql_query("$this-Query",$this-C);
  $this-Cols = @mysql_num_fields($this-Res);
   }


   function FieldName($FileName,$FileLine,$ColNum) {
  if ( $Output = @mysql_field_name($this-Res, $ColNum) ) {
 return $Output;
  } else {
 echo "Field Name Had Problem";
  }
   }


   #  BEGIN ALTERNATIVE TEST FUNCTIONS HERE...

   # Uses MySQL data, but doesn't have the "$Col" argument.
   function Good() {
  for ($Count = 0; $Count  $this-Cols; $Count++) {
 $FieldNames[] = $this-FieldName('test','here', $Count);
 if ( !isset($Col[$FieldNames[$Count]]['hide']) ) {
$VisibleFields++;
echo "$Count = $FieldNames[$Count]. ";
 }
  }
   }


   # Doesn't use MySQL data, but uses "$Col" argument.
   function NoProblem($Col='') {
  for ($Count = 0; $Count  3; $Count++) {
 $FieldNames[] = 'dog';
 $FieldNames[] = 'somename';
 $FieldNames[] = 'cat';
 if ( !isset($Col[$FieldNames[$Count]]['hide']) ) {
$VisibleFields++;
echo "$Count = $FieldNames[$Count]. ";
 }
  }

   }


   # This is the function which causes the problems.
   # Uses MySQL data and has a "$Col" argument.
   function Bad($Col='') {
  for ($Count = 0; $Count  $this-Cols; $Count++) {

 #
 #  "Field Name Call -- Short"
 #
  $FieldNames[] = $this-FieldName('test','here', $Count);

 #
 #  "Field Name Call -- Long"
 #
 # $FieldNames[] = $this-FieldName("FieldName() had error when RSATbl() was 
called by $FileName","$FileLine", $Count);

 #  PROBLEM HAPPENS ON NEXT LINE
 #  Commenting it and the closing } gets the
 #  problems to stop.
 if ( !isset($Col[$FieldNames[$Count]]['hide']) ) {

# Commenting out the following line
# completely shifts the pattern of what
# is okay, crashes and infinite loops!
 $VisibleFields++;

echo "$Count = $FieldNames[$Count]. ";
 }

  }# End of for $Count
   }# End of Bad()
}# End of class


$SQL = new Test;



# TEST SCENARIOS FOR RUNNING THE BAD() FUNCTION


# WHEN:---
#   "Field Name Call -- Short"
#   "$VisibleFields++;" is open
#
# Okay if 1 or 2 Columns:
#   $SQL-Query = "SELECT concat('hi') as H";
#   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B";
# Infinite Loop if 3 Columns:
#   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B, concat('why') as W";
# Crashes if 4 Columns:
   $SQL-Query = "SELECT concat('hi') as H, concat('bye') as B, concat('why') as W, 
concat('oh') as O";


# WHEN:---
#   "Field Name Call -- Long"
#   "$VisibleFields++;" is open
#
# Okay if 1 Column:
#