php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40033 Server Crashes when Throwing an Exception
Submitted: 2007-01-05 15:17 UTC Modified: 2007-01-08 18:40 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:0 of 2 (0.0%)
From: francisco dot a dot castillo at ge dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.2.0 OS: Linux Fedora Core 6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: francisco dot a dot castillo at ge dot com
New email:
PHP Version: OS:

 

 [2007-01-05 15:17 UTC] francisco dot a dot castillo at ge dot com
Description:
------------
I'm running PHP 5.2.0 with Apache 2.2 under a Fedora Core 6 Platform and when I throw a new exception, the server crashes and I prompts me to download the file. I try to throw different exceptions, including ADODB and it stills do the same.

I've checked the logs but the only thing that I see at the apache's one is

[Fri Jan 05 08:52:34 2007] [notice] child pid 14712 exit signal Segmentation fault (11)

Reproduce code:
---------------
			try{
				throw new PHPDevException($this -> error,100,"DAO",$part,false,"SQL","SQL DAO",$qry);				
			}catch (PHPDevException $ac){
				$ac -> toScreen();
				die();
			}	

Expected result:
----------------
Show a screen with the Formatted Exception, Including the description of the class that threw it.

Actual result:
--------------
The browser prompts me to download the file and save it

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-05 15:25 UTC] iliaa@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.


 [2007-01-05 21:00 UTC] francisco dot a dot castillo at ge dot com
This is the backtrace:

#0  0x0120e61a in zif_xsl_xsltprocessor_import_stylesheet (ht=1, return_value=0xa1003c0, return_value_ptr=0x0,
    this_ptr=0xa0fffb0, return_value_used=0) at /http/php-5.2.0/ext/xsl/xsltprocessor.c:387
#1  0x012789d8 in zend_do_fcall_common_helper_SPEC (execute_data=0xbf871ba0) at /http/php-5.2.0/Zend/zend_vm_execute.h:200
#2  0x0126a81d in execute (op_array=0xa0b65c8) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#3  0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf871ec0) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#4  0x0126a81d in execute (op_array=0xa0bdfb4) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#5  0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf872070) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#6  0x0126a81d in execute (op_array=0xa0bb158) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#7  0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf8722a0) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#8  0x0126a81d in execute (op_array=0x9fa8404) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#9  0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf872520) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#10 0x0126a81d in execute (op_array=0x9f9c1a8) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#11 0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf8726f0) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#12 0x0126a81d in execute (op_array=0x9fb8fe0) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#13 0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf872880) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#14 0x0126a81d in execute (op_array=0x9fa5b08) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#15 0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf872a20) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#16 0x0126a81d in execute (op_array=0x9f9d934) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#17 0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf872ec0) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#18 0x0126a81d in execute (op_array=0x9f9db54) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#19 0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf8730c0) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#20 0x0126a81d in execute (op_array=0x9f9eefc) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#21 0x0127844c in zend_do_fcall_common_helper_SPEC (execute_data=0xbf8732c0) at /http/php-5.2.0/Zend/zend_vm_execute.h:234
#22 0x0126a81d in execute (op_array=0x9f9b44c) at /http/php-5.2.0/Zend/zend_vm_execute.h:92
#23 0x0124f1c2 in zend_execute_scripts (type=8, retval=<value optimized out>, file_count=3)
    at /http/php-5.2.0/Zend/zend.c:1097
#24 0x01211a13 in php_execute_script (primary_file=0xbf8755e8) at /http/php-5.2.0/main/main.c:1758
#25 0x012c5420 in php_handler (r=0x9f90328) at /http/php-5.2.0/sapi/apache2handler/sapi_apache2.c:592
#26 0x0807ac59 in ap_run_handler (r=0x9f90328) at config.c:157
#27 0x0807ddc1 in ap_invoke_handler (r=0x9f90328) at config.c:371
#28 0x080c0bb8 in ap_process_request (r=0x9f90328) at http_request.c:258
#29 0x080bdebb in ap_process_http_connection (c=0x9f7e120) at http_core.c:184
#30 0x08081a59 in ap_run_process_connection (c=0x9f7e120) at connection.c:43
#31 0x080d6b50 in child_main (child_num_arg=<value optimized out>) at prefork.c:640
#32 0x080d6db3 in make_child (s=0x9db8b58, slot=0) at prefork.c:680
#33 0x080d7b96 in ap_mpm_run (_pconf=0x9db20a8, plog=0x9dfa1c8, s=0x9db8b58) at prefork.c:956
#34 0x08068a95 in main (argc=165347616, argv=0x9e804a8) at main.c:717
 [2007-01-05 22:01 UTC] iliaa@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2007-01-05 22:07 UTC] francisco dot a dot castillo at ge dot com
Well, I saw that the backtrace threw a problem regarding the XSL, well, I'll paste the code but I use a transformation when throwing an exception, so, I could show it passing an XML to an XSL. This is the code:

Throws the Exception:
try{
  throw new PHPDevException($this -> error,100,"DAO",$part,false,"SQL","SQL DAO",$qry);		   }catch (PHPDevException $ac){
      $ac -> toScreen();
      die();
   }	

The Exception class:

<?
	//require_once("classes/DAO.inc.php");
	//require_once("Config.inc.php");
	require_once("XSLoader.inc.php");
	
	/**
	 * @author Francisco A. Castillo Guerrero. This class handles
	 * all the exceptions created by the assessment center
	 * redesign.
	 */
	class PHPDevException extends Exception{		
		
		protected   $code;
		protected   $message;
		protected   $title;
		protected 	$fclass;
		protected 	$method;
		protected 	$line;
		protected 	$sys;
		protected 	$uri;
		protected 	$sql;
		protected 	$redire;
		
		/**
		 * This is the constructor of the exception class. This method is called when a new
		 * instance is created. This happens when you throw a new PHPDevException.
		 * The parameters that receives are the following:
		 *
		 * @param String 	$errmsg
		 * @param int 		$errcode
		 * @param String 	$class
		 * @param String 	$method
		 * @param boolena 	$redire
		 * @param String 	$title
		 * @param String 	$system
		 * @param String 	$sql
		 */
		public function __construct($errmsg, $errcode, $class, $method, $redire, $title = 'AC', $system = '', $sql = ''){			
			$this -> title = $title;
			$this -> fclass = $class;			
			$this -> method = $method;
			$this -> message = $errmsg;
			$this -> code = $errcode;
			$this -> line = parent::getLine();
			$this -> sys = $system;
			$this -> uri   = $_SERVER['PHP_SELF'];
			$this -> sql = $sql;
			$this -> redire = $redire;
			
			parent::__construct($errmsg,$errcode);
		}
    	
		/**
		 * Inserts into the log table, the content of this Exception.
		 * In the imformation inserted includes parameters from the
		 * same class and are the following:
		 * 
		 * @param Date 		ltime. 		Date of the insertion
		 * @param Long 		time_stamp.	Time stamp of the date
		 * @param String	cname		Class name from the generated exception
		 * @param String	method		Method of the class where the exception was thrown
		 * @param Int		lineNumber	Line where the exception was thrown
		 * @param String	system_name	Name of the system
		 * @param String	uri			Part of the url that generated the exception
		 * @param String	Message		Message of the exception
		 *
		 */
		 
    	public function toLog(){
    	    // Log the content of the Exception.
    	    $dao = new DAO(true);
    	    
    	    $ts = mktime();
    	    $date = date("Y/m/d", $ts);
    	    
    	    
    	    $table = "logger(ltime, time_stamp, cname, method, lineNumber, msg_code, system_name, uri, message)";
    	    $vals = "'$date', $ts,'".
    	    $this -> fclass."','".
    	    $this -> method."',".
    	    $this -> line.",'".
    	    $this -> code."','".
    	    $this -> sys."','".
    	    $this -> uri."','".
    	    $this -> message."'";
    	    
    	    $dao -> insert($table,$vals);
    	    $this -> redir();    		
    	}
    	
    	/**
    	 * Output the exception to the browser
    	 *
    	 */
    	public function toScreen(){
    		
    		$this -> redir();
    		
    		print $this -> formatException($this -> message);    			
    	}
    	
    	/**
    	 * Outputs the exception and save it into the log
    	 *
    	 */
    	public function toBoth(){
    		$this -> redir();
    		$this -> toScreen();
    		$this -> toLog();
    	}
    	
    	/**
    	 * Redirects the page if an exception is raised and if the redirect
    	 * flag is active (true) in the Config file
    	 *
    	 */
    	private function redir(){
    		global $redirect;
    		
    		if($this -> redire === true){
    			//header("Location: $redirect");
    			
    			print "<script>setTimeout('self.location.href=\"$redirect\"',0)</script>";
    		}    		
    	}
    	
    	/**
    	 * This method formats the output to be shown in the browser.
    	 * Only receives the message to format and returns the
    	 * formatted string    	 
    	 *
    	 * @param 	String	msg		Message to format
    	 * @return 	String 	em		The HTML formated string
    	 */
    	private function formatException($msg){
    		$xml = "
			<exception>
			<title>".$this -> title." Exception Raised</title>
			<content>
				<element name='Query'><val>".$this -> sql."</val></element>
				<element name='Class'><val>".$this -> fclass."</val></element>
				<element name='Method'><val>".$this -> method."</val></element>
				<element name='Line Number'><val>".$this -> line."</val></element>
				<element name='Description'><val>".$msg."</val></element>				
			</content>
			</exception>";
    		//print $xml;die();
    		$path = getcwd()."\\exceptions";
    		
		return XSLoader::load($xml,"xslt\\".__CLASS__);
	}
}
?>

The Transformer Class:

<?
	class XSLoader
	{
		/**
		 * Transforms an XML with the XSL received and returns the 
		 * transformed string.
		 *
		 * @param 	String $xml
		 * @param 	String $xsl_file
		 * @return 	String Transformed Document
		 */
		public function load($xml,$xsl_file)
		{
			$doc = new DOMDocument();
			$xsl = new XSLTProcessor();
			
			$doc -> load($xsl_file.'.xsl');
			$xsl -> importStyleSheet($doc);
			
			$doc -> loadXML($xml);
			
			return $xsl -> transformToXML($doc);
		}
	}	
?>

Thanks! Regards!
 [2007-01-08 17:21 UTC] francisco dot a dot castillo at ge dot com
Just write to know what happen with this bug 'cause I haven't received any information of the status. I have my server down because of this.

Thanks for your attention
 [2007-01-08 17:42 UTC] rrichards@php.net
Please try using this CVS snapshot:

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

Looking at the stack trace this looks like same as bug #39625,   so please try a snap.
 [2007-01-08 18:40 UTC] francisco dot a dot castillo at ge dot com
Think this bug is now solved. Similar to bug 39625. Problems with XSLT is solved downloading the latest version of PHP from http://snaps.php.net/. I think you should put in the download area of PHP the latest and correct version of PHP because I downloaded the one that says stable from php.net and I failed.

So, I suggest you put the latest and unbugged version of the 5.2 release.

Thank you for your time.

Regards

Francisco
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 04:01:29 2024 UTC