php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21172 PHP crashed when try to access XML DOM COM interfaces
Submitted: 2002-12-24 07:55 UTC Modified: 2003-01-29 20:03 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: vodmal at newmail dot ru Assigned:
Status: Closed Package: COM related
PHP Version: 4.2.1 OS: Windows 2000
Private report: No CVE-ID: None
 [2002-12-24 07:55 UTC] vodmal at newmail dot ru
test.xml:
<?xml version="1.0"?>

<test a="g" b="false">
	<v val="1">aa</v>
	<v val="2">bb</v>
	<v val="3">nn</v>
</test>

test.php:
<?
	$MSXML = new COM("Msxml2.DOMDocument");

	if ($MSXML->load("D:\\Inetpub\\wwwroot\\vphpmail\\test.xml"))
		{
		$nodeList = $MSXML->getElementsByTagName("v");
		for ($i=0;$i<$nodeList->length;$i++)
			{
			$node = $nodeList->nextNode();
			$attribs = $node->attributes;
			$attr = $attribs->getNamedItem("val");

			echo($attr->Name."<BR>");	// This is crash

			echo($node->nodeName." ".$node->xml."<BR>");
			}
		}
	else
		{
		echo("BAD<br>");
		echo(
			"Error in file <b>".$MSXML->parseError->url."</B> at line <b>".
			$MSXML->parseError->line."</b> in pos <b>".$MSXML->parseError->linepos."</b>");
		}
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-24 17:52 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-12-26 01:57 UTC] vodmal at newmail dot ru
Latest PHP build don't solve this porblem :-\

I am use PHP for Win32 as CGI, may be this information can help fix this problem.
DOM XML -> Microsoft XML Parser 4.? (latest)
 [2003-01-08 20:36 UTC] php_general at e1da dot net
Tried this on Win2KPro SP3, Apache 1.3.27, PHP 4.2.3 and
PHP 4.3.0 (both as module) and get the crash on same line.
Actually as soon as I reference $attr->Name eg
$tmpStr = $attr->Name; // crashes
but if I remove the $attr->Name; line then the
echo($node->nodeName." ".$node->xml."<BR>");
loop works OK.

I am also experiencing crashes when I generate Excel
spreadsheets with 4.3.0. My code generally works fine
under 4.2.3 (except that an excel process is left running
after each time the code is run).
The following seems to be a minimal test case;

<?php
echo "Test started...<br/>\n";
$excel = new COM("Excel.Application") or die("Excel could not be started");

$workbook = "c:\\tmp\\in.xls";// can just be an empty wookbook
$wkb = $excel->application->Workbooks->Open($workbook) or Die ("Did not open");

$sheet = $wkb->Worksheets(1);
$sheet->activate;
$sheet->name='Testing 123'; 

$y=6;
for($i=0;$i<6;$i++){
  $cell = $sheet->Cells($y+$i,1); // Select the cell (Row Column number) 
  $cell->activate; // Activate the cell 
  $cell->value = 'JimBob';
  $cell = $sheet->Cells($y+$i,2);
  $cell->activate;
  $cell->value = 'Yer Baby';
}

$file_name='c:/tmp/adtdump.xls';
if (file_exists($file_name)) {unlink($file_name);} 
$wkb->SaveAs($file_name);
$wkb->Close();

// close the application
$excel->Workbooks->Close();
$excel->ActiveWorkbook->Close("False");
$excel->Quit();
$excel->Release();
$excel = null;
unset($excel); 
?>

If the for loop has $i < 1 then the test will fault one in around five times.
Fault window is;
Microsoft Excel: EXCEL.EXE - Application Error
The instruction at "0x30033ddf" referenced memory at 0x660667f8.
The memory could not be "read".

With $i<10 is faults every time.
and is then usually followed by an Apache Ap error and
Apache restarts the child process (and uptime goes back
 to 0).
With $i<6 it faults most of the time but I haven't seen
an Apache Ap error after the Excel.exe one.

Each time it faults I get an Excel.exe left in taskmanager. If it runs without faulting then I don't.
 [2003-01-29 20:03 UTC] phanto@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC