php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36388 [PATCH]PHP crash when throwing exception and session persistence
Submitted: 2006-02-14 11:15 UTC Modified: 2006-03-02 15:08 UTC
From: david at jool dot nl Assigned: dmitry (profile)
Status: Closed Package: SOAP related
PHP Version: 5CVS-2006-02-14 (snap) OS: winxp
Private report: No CVE-ID: None
 [2006-02-14 11:15 UTC] david at jool dot nl
Description:
------------
When using the soap extension to expose a certain class and setting the persistence to SOAP_PERSISTENCE_SESSION, PHP crashes when I throw an Exception.

Reproduce code:
---------------
<?php
class test1 {
	function soapFunction($param) {
		throw new Exception("something went wrong");
		return "blaat aap: ". $param;
	}
}
if($_GET["type"]=="server") {
	$server = new SOAPServer(null, array("uri"=> "http://some.example.uri/"));
	$server->setClass("test1");
	$server->setPersistence(SOAP_PERSISTENCE_SESSION);
	$server->handle();
} else { //client
	$client = new SOAPClient(null, array('location' => 'http://'.$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"].'?type=server', 'uri'=> 'http://some.example.uri/'));
	$res = $client->__call("soapFunction", array("hey!"));
	var_dump($res);
}
?>

Expected result:
----------------
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in f:\myweb\contentarea\tests\bug_exception.php:15 Stack trace: #0 f:\myweb\contentarea\tests\bug_exception.php(15): SoapClient->__call('soapFunction', Array) #1 {main} thrown in f:\myweb\contentarea\tests\bug_exception.php on line 15

Actual result:
--------------
PHP / Apache crash

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-01 16:27 UTC] david at jool dot nl
Possible patch

--- F:\dev\php 5.1.2\php-src\ext\soap\soap.c	Sun Jan 01 13:50:14 2006
+++ f:\dev\php-modified\ext\soap\soap.c	Wed Mar 01 15:04:19 2006
@@ -1712,7 +1712,7 @@
 		    instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
 			soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
 		} else {
-			if (soap_obj) {zval_ptr_dtor(&soap_obj);}
+			if (soap_obj && service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) {zval_ptr_dtor(&soap_obj);}
 			php_end_ob_buffer(0, 0 TSRMLS_CC);
 			goto fail;
 		}
 [2006-03-02 15:08 UTC] dmitry@php.net
Fix is committed into CVS HEAD and PHP5_1.

Thanks to David.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC