From:             tranelson at x dot com
Operating system: Linux
PHP version:      5.4.9
Package:          FPM related
Bug Type:         Bug
Bug description:FPM incompatible with runkit sanbox

Description:
------------
Using Runkit Sandbox inside PHP-FPM causes FPM to crash.  

Please see the following for a description and GDB trace:

https://github.com/zenovich/runkit/issues/44

I thought this might have been a runkit issue, but in the stack trace,
runkit is just shutting down the child interpreter, which calls back to
FPM.  FPM is assuming that there is a request for this interpreter, which
doesn't hold true in this scenario.   

I've made a fix that works for me.  It is attached below.

Test script:
---------------
   $options = array(
            'safe_mode'=>false,
            'open_basedir'=>'',
            'allow_url_fopen'=>'true',
            'disable_functions'=>'exec,shell_exec,passthru,system',
            'disable_classes'=>'myAppClass');
            
            $sandbox = new Runkit_Sandbox($options);
            $sandbox->eval('echo "hello from sandbox\n";');
            $hello = "hello world from parent";
            echo $hello;


Expected result:
----------------
Hello from sandbox

Actual result:
--------------
Crash.  
#0 fcgi_finish_request (req=0x0, force_close=0)
at /home/tranelson/php-5.4.8/sapi/fpm/fpm/fastcgi.c:1040
#1 0x08440032 in sapi_cgi_deactivate (tsrm_ls=)
at /home/tranelson/php-5.4.8/sapi/fpm/fpm/fpm_main.c:843
#2 sapi_cgi_deactivate (tsrm_ls=0xa6adaf8)
at /home/tranelson/php-5.4.8/sapi/fpm/fpm/fpm_main.c:832
#3 0x0831eaf4 in sapi_deactivate (tsrm_ls=0xa6adaf8)
at /home/tranelson/php-5.4.8/main/SAPI.c:529
#4 0x08315f3c in php_request_shutdown (dummy=0xa6adaf8)
at /home/tranelson/php-5.4.8/main/main.c:1799
#5 0xb68241fb in php_runkit_sandbox_dtor (objval=0xb6a76548,
tsrm_ls=0xa51a070)
at /home/tranelson/runkit/runkit-master/runkit_sandbox.c:1838
#6 0x083ab42c in zend_objects_store_del_ref_by_handle_ex (handle=1,
handlers=0xb68307a0, tsrm_ls=0xa51a070)
at /home/tranelson/php-5.4.8/Zend/zend_objects_API.c:220
#7 0x083ab466 in zend_objects_store_del_ref (zobject=0xb6a7652c,
tsrm_ls=0xa51a070) at
/home/tranelson/php-5.4.8/Zend/zend_objects_API.c:172
#8 0x08380581 in _zval_dtor_func (zvalue=0xb6a7652c)
at /home/tranelson/php-5.4.8/Zend/zend_variables.c:52
#9 0x08371768 in _zval_dtor (zvalue=)
at /home/tranelson/php-5.4.8/Zend/zend_variables.h:35
#10 _zval_ptr_dtor (zval_ptr=0xb6a766ec)
---Type to continue, or q to quit---
at /home/tranelson/php-5.4.8/Zend/zend_execute_API.c:438
#11 _zval_ptr_dtor (zval_ptr=0xb6a766ec)
at /home/tranelson/php-5.4.8/Zend/zend_execute_API.c:427
#12 0x0838f055 in zend_hash_apply_deleter (ht=0xa51bb88, p=0xb6a766e0)
at /home/tranelson/php-5.4.8/Zend/zend_hash.c:650
#13 0x083908e1 in zend_hash_reverse_apply (ht=0xa51bb88,
apply_func=0x8371590 , tsrm_ls=0xa51a070)
at /home/tranelson/php-5.4.8/Zend/zend_hash.c:804
#14 0x08371c1e in shutdown_destructors (tsrm_ls=0xa51a070)
at /home/tranelson/php-5.4.8/Zend/zend_execute_API.c:217
#15 0x08382098 in zend_call_destructors (tsrm_ls=0xa51a070)
at /home/tranelson/php-5.4.8/Zend/zend.c:922
#16 0x08315fc4 in php_request_shutdown (dummy=0x0)
at /home/tranelson/php-5.4.8/main/main.c:1732
#17 0x0806efc2 in main (argc=1, argv=0xbfac87a4)
at /home/tranelson/php-5.4.8/sapi/fpm/fpm/fpm_main.c:1948

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

Reply via email to