From:             maciej dot sz at gmail dot com
Operating system: Linux 3.2.0-25-generic Ubuntu
PHP version:      5.4.4
Package:          Reproducible crash
Bug Type:         Bug
Bug description:Segfault when using traits a lot

Description:
------------
While using traits PHP crashes a lot. This does not seem to be related to
any 
certain piece of code, becouse I just have to add a dummy declaration like
$tmp = '';
and the script runs normally.


For example I just wrote code similar to this:

<?php

trait T1
{
   public function t1()
   {
      return 't1';
   }
}

class Foo
{
   use T1;
}

$f = new Foo();
$f->t1();
?>

and segfault occurred. But all I have to do is add the dummy declaration
within 
the trait method and the script runs normally:

<?php

trait T1
{
   public function t1()
   {
      $tmp = '';
      return 't1';
   }
}

class Foo
{
   use T1;
}

$f = new Foo();
$f->t1();
?>

Sometimes the segfault error disappears by just running the script again.

All scripts are run from command line, my compile configuration is as
follows:
'./configure'  '--with-mysql' '--with-pgsql' '--with-zlib'
'--enable-calendar' 
'--with-curl' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-gd' '--
enable-bcmath' '--enable-soap' '--enable-fpm' '--with-pdo-mysql'
'--with-pdo-
pgsql' '--with-pdo-sqlite' '--with-config-file-path=/etc/php54/cli'
'--with-
config-file-scan-dir=/etc/php54/cli/conf.d' '--prefix=/usr/local/php54'
'--
enable-debug' '--with-mysqli' '--enable-mbstring'

I've recompile PHP several times. This issue appears to consider all 5.4.*

versions.

Here's a bugtrace:

Program received signal SIGSEGV, Segmentation fault.
0x000000000094dafb in zend_get_function_declaration (fptr=0x1669df0)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_compile.c:3052
3052                    memcpy(offset, fptr->common.scope->name, fptr-
>common.scope->name_length);
(gdb) bt
#0  0x000000000094dafb in zend_get_function_declaration (fptr=0x1669df0)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_compile.c:3052
#1  0x000000000094eaf9 in do_inheritance_check_on_method (child=0x16e15d8,

parent=0x1680028)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_compile.c:3263
#2  0x000000000094ecaf in do_inherit_method_check 
(child_function_table=0x16e1118, parent=0x1680028, 
    hash_key=0x7fffffff9db0, child_ce=0x16e10f0)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_compile.c:3288
#3  0x00000000009881ec in zend_hash_replace_checker_wrapper
(target=0x16e1118, 
source_data=0x1680028, 
    p=0x167ff80, pParam=0x16e10f0, merge_checker_func=0x94ec28 
<do_inherit_method_check>)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_hash.c:878
#4  0x000000000098826d in zend_hash_merge_ex (target=0x16e1118, 
source=0x1668390, 
    pCopyConstructor=0x94d531 <do_inherit_method>, size=240, 
    pMergeSource=0x94ec28 <do_inherit_method_check>, pParam=0x16e10f0)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_hash.c:892
#5  0x000000000094ff5d in zend_do_inheritance (ce=0x16e10f0, 
parent_ce=0x1668368)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_compile.c:3519
#6  0x0000000000953796 in do_bind_inherited_class (op_array=0x16e2270, 
opline=0x16eacd8, 
    class_table=0x126ce70, parent_ce=0x1668368, compile_time=0 '\000')
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_compile.c:4569
#7  0x00000000009b6a49 in ZEND_DECLARE_INHERITED_CLASS_SPEC_HANDLER 
(execute_data=0x7ffff7f96538)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_vm_execute.h:936
#8  0x00000000009b3741 in execute (op_array=0x16e2270)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_vm_execute.h:410
#9  0x0000000000962f23 in zend_call_function (fci=0x7fffffffa3f0, 
fci_cache=0x7fffffffa440)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_execute_API.c:958
#10 0x0000000000716989 in zim_reflection_method_invokeArgs (ht=2, 
return_value=0x16d6960, 
---Type <return> to continue, or q <return> to quit---
    return_value_ptr=0x0, this_ptr=0x164abb0, return_value_used=1)
    at /home/maciek/Pobrane/php-5.4.4/ext/reflection/php_reflection.c:2926
#11 0x00000000009b4e57 in zend_do_fcall_common_helper_SPEC 
(execute_data=0x7ffff7f94a38)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_vm_execute.h:642
#12 0x00000000009b5cfb in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER 
(execute_data=0x7ffff7f94a38)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_vm_execute.h:752
#13 0x00000000009b3741 in execute (op_array=0x7ffff0d7e680)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend_vm_execute.h:410
#14 0x00000000009762b2 in zend_execute_scripts (type=8, retval=0x0, 
file_count=3)
    at /home/maciek/Pobrane/php-5.4.4/Zend/zend.c:1279
#15 0x00000000008e8a1a in php_execute_script (primary_file=0x7fffffffcda0)
    at /home/maciek/Pobrane/php-5.4.4/main/main.c:2473
#16 0x0000000000abee99 in do_cli (argc=6, argv=0x7fffffffe188)
    at /home/maciek/Pobrane/php-5.4.4/sapi/cli/php_cli.c:988
#17 0x0000000000abffb9 in main (argc=6, argv=0x7fffffffe188)
    at /home/maciek/Pobrane/php-5.4.4/sapi/cli/php_cli.c:1361

Expected result:
----------------
Script exited normally, without segfault.

Actual result:
--------------
Segmentation fault.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62358&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62358&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62358&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62358&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62358&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62358&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62358&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62358&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62358&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62358&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62358&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62358&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62358&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62358&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62358&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62358&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62358&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62358&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62358&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62358&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62358&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62358&r=mysqlcfg

Reply via email to