# Assist in debugging a crash.

- Thread: https://externals.io/message/25258
- Original archive: https://news-web.php.net/php.internals/25258
- Started by Richard Quadling on 2006-08-09T10:41:44+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #25258 — Richard Quadling — 2006-08-09T10:41:44+00:00

URL: https://externals.io/message/25258#25258

Hi.

I'm getting a crash with the new Win32 Snapshot - PHP 5.2.0RC2-dev
(cli) (built: Aug  9 2006 08:20:48) / PHP Version 5.2.0RC2-dev Build
Date Aug 9 2006 08:15:12 (for ISAPI)

(From DrWatson for CLI)
AppName: php.exe	 AppVer: 5.2.0.0	 ModName: php5ts.dll
ModVer: 5.2.0.0	 Offset: 00009f78

(From Browser for ISAPI)
PHP has encountered an Access Violation at 00F19F78



Using Depends.exe, that address is closest to _zend_mm_free (0x9D30)
and _zend_mm_realloc (0xA030)

These functions follow each other in zend_alloc.c.

The userland code was working before I upgraded the snapshot.

I've done all the usual stuff like removing extensions and Zend
Optimizer. I'm having the problem with the CLI and ISAPI versions.

What can I do to identify the problem further.

The script which causes the problem is quite large. I'm not able to
reproduce a simple case for the problem.

Is there a debug version available for PHP and if so, what debugger
should I use?

The actual line of code for which the script fails is trivial (the
echos are debugs I've added to find the problem) ...

// Works.
$headers = str_replace(CRLF.'.', CRLF.'..', trim(implode(CRLF,
$this->headers)));
echo "\n\n" , __FILE__, ' ' , __LINE__, ' ', strlen($this->body);

// Crashes.
$body    = str_replace(CRLF . '.', CRLF . '..', $this->body);
echo "\n\n" , __FILE__, ' ' , __LINE__;


If I ...

// Works.
$headers = str_replace(CRLF.'.', CRLF.'..', trim(implode(CRLF,
$this->headers)));
echo "\n\n" , __FILE__, ' ' , __LINE__, ' ', strlen($this->body);

// Works.
$b1 = $this->body;
echo "\n\n" , __FILE__, ' ' , __LINE__, ' ', strlen($b1), ' ',
strlen($this->body);

// Crashes.
$body    = str_replace("\r\n.", "\r\n..", $b1);
echo "\n\n" , __FILE__, ' ' , __LINE__;


If I ...

// Works.
$headers = str_replace(CRLF.'.', CRLF.'..', trim(implode(CRLF,
$this->headers)));
echo "\n\n" , __FILE__, ' ' , __LINE__, ' ', strlen($this->body);

// Works.
$b1 = $this->body;
echo "\n\n" , __FILE__, ' ' , __LINE__, ' ', strlen($b1), ' ',
strlen($this->body);

// File saved and then crash.
$b2 = file_put_contents('C:/data.txt', $b1);

// Not reached.
echo "\n\n" , __FILE__, ' ' , __LINE__, ' ', var_export($b2, True);

$body    = str_replace("\r\n.", "\r\n..", $b1);
echo "\n\n" , __FILE__, ' ' , __LINE__;


I looked at the data directly. The data is an HTML email with some CSS
in it. Some of the CSS is like ...

/* Success's have a green background */
.MAction_Success_TH
	{
	background-color : #00FF00;
	}

.MTable_Action_TD
	{
	background-color : #DFDFDF;
	}

.MTitle_Action_TH
	{
	background-color : #7F7FFF;
	}

.MTitle_TH
	{
	background-color : #007FFF;
	}


By putting a space in front of the '.',  this has solved the problem. e.g.

/* Success's have a green background */
 .MAction_Success_TH
	{
	background-color : #00FF00;
	}

 .MTable_Action_TD
	{
	background-color : #DFDFDF;
	}

 .MTitle_Action_TH
	{
	background-color : #7F7FFF;
	}

 .MTitle_TH
	{
	background-color : #007FFF;
	}


I've NO idea why. Please remember that the code was working BEFORE the
snapshot and I've been stupid and not kept the old version. I will in
future.


-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&amp;r=213474731
"Standing on the shoulders of some very clever giants!"
