From:             antony at zend dot com
Operating system: Linux
PHP version:      5CVS-2005-06-18 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  double free() when exporting a ReflectionClass

Description:
------------
Memory related errors while freeing resources after export()ing certain
ReflectionClass object.
Tested with latest 5.1-CVS and 5.0.5-CVS.
See details below.

Reproduce code:
---------------
<?php
class Test {
    function foo($arg2=false) {
    }
    function bar() {
    }
}

Reflection::export(new ReflectionClass('Test'));
?>

Expected result:
----------------
.

Actual result:
--------------
With Zend MM enabled:

Warning: String is not zero-terminated (Z*Z*) (source:
/usr/src/dev/php-src_head/Zend/zend_variables.h:35) in Unknown on line 0
[Sat Jun 18 02:20:58 2005]  Script:  'index.php'
---------------------------------------
/usr/src/dev/php-src_head/Zend/zend_variables.h(35) : Block 0x0845EAE8
status:
/usr/src/dev/php-src_head/Zend/zend_variables.c(36) : Actual location
(location was relayed)
Beginning:      Cached (allocated on
/usr/src/dev/php-src_head/Zend/zend.c:205, 1 bytes)
      End:      OK
---------------------------------------

With Zend MM disabled:

Warning: String is not zero-terminated &#65533;&#65533;@) (source:
/usr/src/dev/clean/php-src_head/Zend/zend_variables.h:35) in Unknown on
line 0
*** glibc detected *** double free or corruption (!prev): 0x08382470 ***

Valgrind output:

==17469== Invalid read of size 1
==17469==    at 0x81AC287: _zval_dtor_func (zend_variables.c:35)
==17469==    by 0x81A5ED0: _zval_dtor (zend_variables.h:35)
==17469==    by 0x81A58B4: destroy_op_array (zend_opcode.c:236)
==17469==    by 0x81A54ED: destroy_zend_function (zend_opcode.c:109)
==17469==    by 0x81A5503: zend_function_dtor (zend_opcode.c:121)
==17469==    by 0x81B4FCB: zend_hash_destroy (zend_hash.c:519)
==17469==    by 0x81A5628: destroy_zend_class (zend_opcode.c:164)
==17469==    by 0x81B4F05: zend_hash_del_key_or_index (zend_hash.c:490)
==17469==    by 0x81B55C6: zend_hash_reverse_apply (zend_hash.c:736)
==17469==    by 0x81A1828: shutdown_executor (zend_execute_API.c:264)
==17469==  Address 0x1BDA99C5 is 5 bytes inside a block of size 6 free'd
==17469==    at 0x1B9060B1: free (in
/usr/lib/valgrind/vgpreload_memcheck.so)
==17469==    by 0x81A1DBD: zval_update_constant (zend_execute_API.c:442)
==17469==    by 0x81C76D9: _parameter_string (zend_reflection_api.c:565)
==17469==    by 0x81C7884: _function_parameter_string
(zend_reflection_api.c:601)
==17469==    by 0x81C7B39: _function_string (zend_reflection_api.c:670)
==17469==    by 0x81C741D: _class_string (zend_reflection_api.c:486)
==17469==    by 0x81CC8FF: zif_reflection_class___toString
(zend_reflection_api.c:2477)
==17469==    by 0x81A31BE: zend_call_function (zend_execute_API.c:867)
==17469==    by 0x81A2279: call_user_function_ex (zend_execute_API.c:555)
==17469==    by 0x81C8E62: zif_reflection_export
(zend_reflection_api.c:1127)
==17469==
==17469== Invalid free() / delete / delete[]
==17469==    at 0x1B9060B1: free (in
/usr/lib/valgrind/vgpreload_memcheck.so)
==17469==    by 0x81AC2BD: _zval_dtor_func (zend_variables.c:36)
==17469==    by 0x81A5ED0: _zval_dtor (zend_variables.h:35)
==17469==    by 0x81A58B4: destroy_op_array (zend_opcode.c:236)
==17469==    by 0x81A54ED: destroy_zend_function (zend_opcode.c:109)
==17469==    by 0x81A5503: zend_function_dtor (zend_opcode.c:121)
==17469==    by 0x81B4FCB: zend_hash_destroy (zend_hash.c:519)
==17469==    by 0x81A5628: destroy_zend_class (zend_opcode.c:164)
==17469==    by 0x81B4F05: zend_hash_del_key_or_index (zend_hash.c:490)
==17469==    by 0x81B55C6: zend_hash_reverse_apply (zend_hash.c:736)
==17469==  Address 0x1BDA99C0 is 0 bytes inside a block of size 6 free'd
==17469==    at 0x1B9060B1: free (in
/usr/lib/valgrind/vgpreload_memcheck.so)
==17469==    by 0x81A1DBD: zval_update_constant (zend_execute_API.c:442)
==17469==    by 0x81C76D9: _parameter_string (zend_reflection_api.c:565)
==17469==    by 0x81C7884: _function_parameter_string
(zend_reflection_api.c:601)
==17469==    by 0x81C7B39: _function_string (zend_reflection_api.c:670)
==17469==    by 0x81C741D: _class_string (zend_reflection_api.c:486)
==17469==    by 0x81CC8FF: zif_reflection_class___toString
(zend_reflection_api.c:2477)
==17469==    by 0x81A31BE: zend_call_function (zend_execute_API.c:867)
==17469==    by 0x81A2279: call_user_function_ex (zend_execute_API.c:555)
==17469==    by 0x81C8E62: zif_reflection_export
(zend_reflection_api.c:1127)



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

Reply via email to