php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30163 Segmentation fault with not catched exception
Submitted: 2004-09-20 09:39 UTC Modified: 2004-09-27 08:11 UTC
From: guth at fiifo dot u-psud dot fr Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.1 OS: Linux (mandrake 10)
Private report: No CVE-ID: None
 [2004-09-20 09:39 UTC] guth at fiifo dot u-psud dot fr
Description:
------------
[ bad english, i know ]

It seems that PHP 5 is not very stable.
My code segfaults every 3-4 days :'(

Reproduce code:
---------------
<?php

class B {
}

class A {
	public $b;
	public function __construct() {
		$this->b = new B;
	}
	public function build() {
		return $this->b;
	}
}

class C {

	private $b;

	public function __construct() {
		
		$a = new A();
		$this->b = $a->build();
		
		try {
			throw new Exception;
		} catch(Exception $e) {
		}

	}

	public function __destruct() {
	
		throw new Exception;

	}

}

$C = new C;

?>

Expected result:
----------------
Something like "An uncaught exception has been thrown..."

Note that the code works as expected if you remove the following lines :

"$a = new A();
$this->b = $a->build();"

Actual result:
--------------
segmentation fault :)

(gdb) bt
#0  0x08205ec8 in zend_objects_destroy_object (object=0x831ae6c, handle=3) at /usr/src/php-5.0.1/Zend/zend_objects.c:37
#1  0x082089ec in zend_objects_store_del_ref (zobject=0x831ae2c) at /usr/src/php-5.0.1/Zend/zend_objects_API.c:144
#2  0x081efe22 in _zval_dtor (zvalue=0x831ae2c, __zend_filename=0x82641e0 "/usr/src/php-5.0.1/Zend/zend_execute_API.c",
    __zend_lineno=391) at /usr/src/php-5.0.1/Zend/zend_variables.c:61
#3  0x081e465c in _zval_ptr_dtor (zval_ptr=0x8307848,
    __zend_filename=0x8265100 "/usr/src/php-5.0.1/Zend/zend_variables.c", __zend_lineno=193)
    at /usr/src/php-5.0.1/Zend/zend_execute_API.c:391
#4  0x081f0174 in _zval_ptr_dtor_wrapper (zval_ptr=0x8307848) at /usr/src/php-5.0.1/Zend/zend_variables.c:193
#5  0x081f96c4 in zend_hash_destroy (ht=0x8313e7c) at /usr/src/php-5.0.1/Zend/zend_hash.c:519
#6  0x0820612e in zend_objects_free_object_storage (object=0x831ac04) at /usr/src/php-5.0.1/Zend/zend_objects.c:88
#7  0x08208749 in zend_objects_store_free_object_storage (objects=0x8288664)
    at /usr/src/php-5.0.1/Zend/zend_objects_API.c:72
#8  0x081e418b in shutdown_executor () at /usr/src/php-5.0.1/Zend/zend_execute_API.c:272
#9  0x081f17c3 in zend_deactivate () at /usr/src/php-5.0.1/Zend/zend.c:819
#10 0x081aa454 in php_request_shutdown (dummy=0x0) at /usr/src/php-5.0.1/main/main.c:1212
#11 0x082232b8 in main (argc=2, argv=0xbffff624) at /usr/src/php-5.0.1/sapi/cli/php_cli.c:1046

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-26 15:30 UTC] magnus@php.net
Please try using this CVS snapshot:

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

I ran the code atleast 50 times and it works just fine here.
 [2004-09-26 16:11 UTC] guth at fiifo dot u-psud dot fr
It works fine with the latest CVS.
I don't get the segmentation fault any more.

Thank you.
 [2004-09-27 08:11 UTC] magnus@php.net
User reports that it works fine with latest snapshot.
Closing.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun May 24 14:00:01 2026 UTC