#27895 [Com]: Access violation while throwing exception

From: Date: Wed, 07 Apr 2004 09:25:05 +0000
Subject: #27895 [Com]: Access violation while throwing exception
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-57644@lists.php.net to get a copy of this message
ID: 27895 Comment by: jevon at jevon dot org Reported By: mes at zeroc dot com Status: Feedback Bug Type: Zend Engine 2 problem Operating System: Windows 2000/XP PHP Version: 5.0.0RC1 New Comment: (Oops, my report isn't using the new snapshot.) Previous Comments: ------------------------------------------------------------------------ [2004-04-07 05:23:55] jevon at jevon dot org I can occasionally get it to crash with almost any exception too, thrown outside of a class, like so: <?php class E extends Exception { } // don't know if this makes a difference try { throw new E(); } catch (Exception $e) { // do nothing - don't know if this makes a difference } echo "42"; ?> Access Violations occur less frequently, but still do occur. Access violations are more likely to be caused, the more complex the script becomes. A small 4000-line web application (I can share source) almost NEVER runs without an Access Violation (but it does occasionally!) I can show that the number of times required to run the script before crash is indeed random: <?php for ($j = 0; $j < 50; $j++) { for ($i = 0; $i < 100; $i++) { if (($str = file_get_contents("http://url_to_script?$i")) != "42") { echo $i . "access violation [$str]"; break; } else { $s++; } } } ?> By echoing $i repeatedly, sometimes it will never fail; other times it will repeatedly crash after 1-10 file_get_contents()s. I guess it's a problem with memory allocation? I get a lot of Access Violations and can't continue developing with them all. OS: Windows XP Pro SP1 Server: Microsoft IIS 5.1 MySQL: 4.1.1 alpha PHP: 5.0RC1 Keep up the good work :) ------------------------------------------------------------------------ [2004-04-07 05:15:06] sniper@php.net Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2004-04-07 05:14:59] sniper@php.net Does not crash within Linux (debug/no-debug) ------------------------------------------------------------------------ [2004-04-06 22:14:28] mes at zeroc dot com Description: ------------ I'm using PHP 5.0.0RC1 and Apache 2.0.49 on Windows 2000 & XP. After executing the enclosed script a number of times, I eventually receive an Access Violation notice. Sometimes it happens after two executions, sometimes after 20, but it always happens. I initially used the binary distributions of PHP5 and Apache, but I've also compiled Apache and PHP5 from sources using VC 6.0 and VC 7.0, with the same result. Unfortunately, the problem only appears when I compile in release mode, not in debug mode. However, I believe the problem occurs in the first while loop of zend_fetch_debug_backtrace, where the args variable eventually points to an invalid location and is then dereferenced. Reproduce code: --------------- <HTML> <HEAD> <TITLE>Access Violation Demo</TITLE> </HEAD> <BODY> <H1>Access Violation Demo</H1> <?php if(isset($_POST["submitted"])) { echo "<HR>\n"; echo "<P>Status:<BR><B>\n"; try { throw new Exception; } catch(Exception $ex) { echo "<pre>\n"; print_r($ex); echo "</pre>\n"; } echo "</B></P>\n"; echo "<HR>\n"; } ?> <P> <FORM method="POST" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>"> <INPUT type="hidden" name="submitted" value="yes"> <INPUT type="submit" name="Submit" value="Submit"> </FORM> </BODY> </HTML> Expected result: ---------------- Access violation dialog Actual result: -------------- Can't get a useful stack trace because it doesn't seem to happen in debug mode. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27895&edit=1

« previous php.bugs (#57644) next »