From:             mep_eisen at web dot de
Operating system: Linux
PHP version:      5.0.0b3 (beta3)
PHP Bug Type:     Reproducible crash
Bug description:  dl() defining classes, segfault shutdown-sequence

Description:
------------
I got a segfault writing my own extension. Searching for any solutions I
found a post in php.internals from Ilia Alshanetsky <[EMAIL PROTECTED]> at
2004/01/09 06:11.

If you load an extension using function dl() and leave some undeleted
objects at the end of script, php seems to crash. (see code from Ilia
below...)

To reproduce the problem you need to compile the extension as shared
object. I used the client sapi executable "php" of php5.0.0b3 and
php5-200401171030.

Reproduce code:
---------------
this code crashes
-------
dl("date.so");
$a = new date();
-------

this code does not crash
-------
dl("date.so");
$a = new date();
$a = null;
-------


Expected result:
----------------
The global objects should be destroyed before there class definitions are
unloaded.


Actual result:
--------------
segfault in
zend_variables.c:61
        ZEND_OBJ_HT_P(zvalue)->del_ref(zavlue TSRMLS_CC);

seems that the class definitions an extension defines are lost (the
extension is unloaded) before the created variables are destroyed.
object_handlers table is destroyed. If you set your object to null inside
php script or if you destroy all public variables inside module shutdown
sequence it works fine...

        $a=null;
works fine.

code block from php_request_shutdown() (main.c:1216)

        if (PG(modules_activated)) {
                zend_deactivate_modules(TSRMLS_C);   // modules are
unloaded
        }
[...]
        zend_deactivate(TSRMLS_C); // variables are destroyed inside here


backtrace:
(gdb) frame 7
#7  0x081a53ba in main (argc=2, argv=0xbffff374) at
/home/mepeisen/projects/php/php-5.0.0b3/sapi/cli/php_cli.c:1013
(gdb) frame 6
#6  0x0813e920 in php_request_shutdown (dummy=0x0) at
/home/mepeisen/projects/php/php-5.0.0b3/main/main.c:1246
(gdb) frame 5
#5  0x08173510 in zend_deactivate () at
/home/mepeisen/projects/php/php-5.0.0b3/Zend/zend.c:810
/home/mepeisen/projects/php/php-5.0.0b3/Zend/zend.c:810:24099:beg:0x8173510
(gdb) frame 4
#4  0x0816a64e in shutdown_executor () at
/home/mepeisen/projects/php/php-5.0.0b3/Zend/zend_execute_API.c:210
/home/mepeisen/projects/php/php-5.0.0b3/Zend/zend_execute_API.c:210:6236:beg:0x816a64e
(gdb) frame 3
#3  0x0817a019 in zend_hash_graceful_reverse_destroy (ht=0x81f7e30) at
/home/mepeisen/projects/php/php-5.0.0b3/Zend/zend_hash.c:634
(gdb) frame 2
#2  0x08179f59 in zend_hash_apply_deleter (ht=0x81f7e30, p=0x40384be4) at
/home/mepeisen/projects/php/php-5.0.0b3/Zend/zend_hash.c:568
(gdb) frame 1
#1  0x0816a9a9 in _zval_ptr_dtor (zval_ptr=0x40384bf0) at
/home/mepeisen/projects/php/php-5.0.0b3/Zend/zend_execute_API.c:354
(gdb) frame 0
#0  0x08172138 in _zval_dtor (zvalue=0x40383d7c) at
/home/mepeisen/projects/php/php-5.0.0b3/Zend/zend_variables.c:61


-- 
Edit bug report at http://bugs.php.net/?id=26945&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26945&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26945&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26945&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26945&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26945&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26945&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26945&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26945&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26945&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26945&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26945&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26945&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26945&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26945&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26945&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26945&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26945&r=float

Reply via email to