Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault with fetching and opcache #1855

Closed
Jurigag opened this issue Apr 30, 2019 · 13 comments

Comments

Projects
None yet
3 participants
@Jurigag
Copy link
Member

commented Apr 30, 2019

When fetched value is empty array there are weird issues when using php7.2-fpm and opcache(doesn't happen with opcache disabled):

Zephir code:

namespace Fetchtest;

class Test
{
        protected _moduleName = null;

        protected _namespaceName = null;

        protected _handlerName = null;

        protected _actionName = null;

        protected _params = [];

        protected _finished = false;

        protected _forwarded = false;

        public function testFetch(var forward)
        {
            var namespaceName, controllerName, params, actionName, taskName;

            if fetch params, forward["params"] {
                let this->_params = params;
            }

            // Check if we need to forward to another controller.
            if fetch controllerName, forward["controller"] {
                let this->_handlerName = controllerName;
            } elseif fetch taskName, forward["task"] {
                let this->_handlerName = taskName;
            }

            // Check if we need to forward to another action
            if fetch actionName, forward["action"] {
                let this->_actionName = actionName;
            }

            // Check if we need to forward changing the current parameters
            if fetch params, forward["params"] {
                let this->_params = params;
            }

            let this->_finished = false,
                 this->_forwarded = true;
        }
}

PHP code:

<?php

$test = new \Fetchtest\Test();
$test->testFetch(['controller' => 'mobile', 'params' => [],]);
$test->testFetch(['controller' => 'mobile', 'params' => [],]);
$test->testFetch(['controller' => 'mobile', 'params' => [],]);
$test->testFetch(['controller' => 'mobile', 'params' => [],]);
$test->testFetch(['controller' => 'mobile', 'params' => [],]);
$test->testFetch(['controller' => 'mobile', 'params' => [],]);
var_dump($test);

php -v:

PHP 7.2.17-0ubuntu0.18.04.1 (cli) (built: Apr 18 2019 14:12:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Tested on ubuntu 18.04

I reproduced this on both zephir 0.10.x and developement branch. It only fails under fpm + opcache - after many requests, i guess it's matter of php-fpm process having opcache or not. It works on cli + opcache(with configured opcache dir).

It only happens on empty array, if i remove this key or change value of it to anything else it works correctly.

On develpement branch of zephir there are either error 500 with out of memory errors or seg faults like those or sometimes wrong value returned(not empty array, instead there is array returned with controller and params keys):

Program terminated with signal SIGSEGV, Segmentation fault.
#0  zend_array_dup_element (with_holes=1, static_keys=0, packed=0, q=0x7f23c6001008, p=0x0, idx=0, target=0x7f23c6064118, source=0x7f23c6063268) at ./Zend/zend_hash.c:1664
1664	./Zend/zend_hash.c: No such file or directory.
(gdb) bt
#0  zend_array_dup_element (with_holes=1, static_keys=0, packed=0, q=0x7f23c6001008, p=0x0, idx=0, target=0x7f23c6064118, source=0x7f23c6063268) at ./Zend/zend_hash.c:1664
#1  zend_array_dup_elements (with_holes=<optimized out>, static_keys=<optimized out>, target=<optimized out>, source=<optimized out>) at ./Zend/zend_hash.c:1737
#2  zend_array_dup (source=0x7f23c6063268) at ./Zend/zend_hash.c:1838
#3  0x00007f23c25e6aab in zephir_update_property_zval (object=0x7f23c601f0c0, property_name=0x7f23c2603912 "_params", property_length=7, value=0x7ffd6ccc8480) at /root/fetchtest/ext/kernel/object.c:574
#4  0x00007f23c2601677 in zim_Fetchtest_Test_testFetch (execute_data=0x7f23c601f0a0, return_value=0x7ffd6ccc8520) at /root/fetchtest/ext/fetchtest/test.zep.c:77
#5  0x000055647a4010e8 in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER () at ./Zend/zend_vm_execute.h:907
#6  execute_ex (ex=0x18c0c66000) at ./Zend/zend_vm_execute.h:59765
#7  0x000055647a4021f7 in zend_execute (op_array=op_array@entry=0x7f23c6072000, return_value=return_value@entry=0x7f23990dca80) at ./Zend/zend_vm_execute.h:63776
#8  0x000055647a350b72 in zend_execute_scripts (type=type@entry=8, retval=0x7f23990dca80, retval@entry=0x0, file_count=-972951504, file_count@entry=3) at ./Zend/zend.c:1498
#9  0x000055647a2ec6a0 in php_execute_script (primary_file=0x7ffd6cccab30) at ./main/main.c:2594
#10 0x000055647a19c79b in main (argc=<optimized out>, argv=<optimized out>) at ./sapi/fpm/fpm/fpm_main.c:1966
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:423
423	../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) bt
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:423
#1  0x000055d076595d4e in memcpy (__len=<optimized out>, __src=<optimized out>, __dest=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
#2  zend_array_dup (source=0x7f31ade63268) at ./Zend/zend_hash.c:1787
#3  0x00007f31aa3e6aab in zephir_update_property_zval (object=0x7f31ade1d0c0, property_name=0x7f31aa403912 "_params", property_length=7, value=0x7ffcbb917560) at /root/fetchtest/ext/kernel/object.c:574
#4  0x00007f31aa40145c in zim_Fetchtest_Test_testFetch (execute_data=0x7f31ade1d0a0, return_value=0x7ffcbb917600) at /root/fetchtest/ext/fetchtest/test.zep.c:64
#5  0x000055d0766330e8 in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER () at ./Zend/zend_vm_execute.h:907
#6  execute_ex (ex=0x7f31ade01000) at ./Zend/zend_vm_execute.h:59765
#7  0x000055d0766341f7 in zend_execute (op_array=op_array@entry=0x7f31ade72000, return_value=return_value@entry=0x7f3180edca80) at ./Zend/zend_vm_execute.h:63776
#8  0x000055d076582b72 in zend_execute_scripts (type=type@entry=8, retval=0x7f3180edca80, retval@entry=0x0, file_count=-1377710032, file_count@entry=3) at ./Zend/zend.c:1498
#9  0x000055d07651e6a0 in php_execute_script (primary_file=0x7ffcbb919c10) at ./main/main.c:2594
#10 0x000055d0763ce79b in main (argc=<optimized out>, argv=<optimized out>) at ./sapi/fpm/fpm/fpm_main.c:1966

On 0.10.x branch i have sometimes seg fault ending like this:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fbacd8b87db in zephir_ensure_array (zv=0x7fbabd931e68) at /root/cphalcon/ext/kernel/array.c:81
81			zend_hash_num_elements(Z_ARRVAL_P(zv)) == 0 &&
(gdb) bt
#0  0x00007fbacd8b87db in zephir_ensure_array (zv=0x7fbabd931e68) at /root/cphalcon/ext/kernel/array.c:81
#1  0x00007fbacd8b8cc7 in zephir_array_isset_string_fetch (fetched=0x7ffe84658110, arr=0x7fbaea21d430, index=0x7fbace112cef "params", index_length=6, readonly=1) at /root/cphalcon/ext/kernel/array.c:151

Or i have weird value returned:

object(Fetchtest\Test)#1 (7) { ["_moduleName":protected]=> NULL ["_namespaceName":protected]=> NULL ["_handlerName":protected]=> string(6) "mobile" ["_actionName":protected]=> NULL ["_params":protected]=> array(1) { [0]=> UNKNOWN:0 } ["_finished":protected]=> bool(false) ["_forwarded":protected]=> bool(true) }

Do you have any idea @dreamsxin ?

@Jurigag Jurigag changed the title Segfault with fetch and opcache Segfault with fetching and opcache Apr 30, 2019

@Jurigag Jurigag added the bug label Apr 30, 2019

@dreamsxin

This comment has been minimized.

Copy link
Member

commented May 1, 2019

@dreamsxin dreamsxin referenced this issue May 2, 2019

Merged

Fix #1855 #1856

1 of 3 tasks complete
@zsilbi

This comment has been minimized.

Copy link

commented May 3, 2019

Thanks @dreamsxin, this fixed my problems as well.
I had a similar issue when I tried to copy an array like this:

namespace Phalcon\Mvc;

class Model {
   public arrayOne = [];
   public arrayTwo = [];

   public function test() {
      ...
      this->arrayOne = this->arrayTwo;
      ...
   }
}

This was the result:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000563b01ad2a12 in _emalloc_56 ()
#1  0x0000563b01b0b35c in zend_array_dup ()
#2  0x00007f037521b314 in zephir_call_user_function (object_pp=0x0, obj_ce=0x0, type=zephir_fcall_function, function_name=0x7ffc642115c0, retval_ptr=0x7ffc64211ad0, cache_entry=0x7ffc64211210, cache_slot=344, param_count=2,
    params=0x7ffc64211b90) at /cphalcon/ext/kernel/fcall.c:425
#3  0x00007f037521b59d in zephir_call_func_aparams (return_value_ptr=0x7ffc64211ad0, func_name=0x7f0376b2b29e "array_diff", func_length=10, cache_entry=0x0, cache_slot=344, param_count=2, params=0x7ffc64211b90)
    at /cphalcon/ext/kernel/fcall.c:450

zsilbi pushed a commit to zsilbi/cphalcon that referenced this issue May 3, 2019

@dreamsxin

This comment has been minimized.

Copy link
Member

commented May 4, 2019

@zsilbi I get.

zsilbi pushed a commit to zsilbi/cphalcon that referenced this issue May 5, 2019

@dreamsxin dreamsxin closed this in 2a5b0f3 May 5, 2019

@Jurigag

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

Looks like it works.

@Jurigag

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

Any idea how can i backport this to zephir 0.10.x? Just copied your code from PR but it creates then yet another seg fault somewhere else. Issue was happening for me on phalcon 3.4.3, and unforunately zephir 0.11.x and later doesn't support phalcon 3.4.x @dreamsxin

@dreamsxin

This comment has been minimized.

Copy link
Member

commented May 6, 2019

@Jurigag Much change on the 0.11.x,you can put the core dump, i try fix it.

@Jurigag

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

Unforunately only have code with phalcon calls:

#0  zend_mm_alloc_small (bin_num=6, size=56, heap=0x7f4883800040) at ./Zend/zend_alloc.c:1275
#1  _emalloc_56 () at ./Zend/zend_alloc.c:2354
#2  0x000056081d4f8dc0 in _array_init (arg=0x7ffd6d5c1e90, size=2) at ./Zend/zend_API.c:1090
#3  0x00007f4866edef83 in resolve_callable (retval=0x7ffd6d5c1e90, type=zephir_fcall_method, ce=0x7f48540e2c80, object=0x7f488381f930, 
    function=0x7ffd6d5c2150) at /root/cphalcon/ext/kernel/fcall.c:169
#4  0x00007f4866edfca3 in zephir_call_user_function (object_pp=0x7f488381f930, obj_ce=0x7f48540e2c80, type=zephir_fcall_method, 
    function_name=0x7ffd6d5c2150, retval_ptr=0x0, cache_entry=0x0, cache_slot=0, param_count=0, params=0x7ffd6d5c2320)
    at /root/cphalcon/ext/kernel/fcall.c:363
#5  0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x0, ce=0x7f48540e2c80, type=zephir_fcall_method, object=0x7f488381f930, 
    method_name=0x7f48838dd2e0 "afterfetch", method_len=10, cache_entry=0x0, cache_slot=0, param_count=0, params=0x7ffd6d5c2320)
    at /root/cphalcon/ext/kernel/fcall.c:523
#6  0x00007f48672facd2 in zim_Phalcon_Mvc_Model_fireEvent (execute_data=0x7f488381f910, return_value=0x7ffd6d5c25b0)
    at /root/cphalcon/ext/phalcon/mvc/model.zep.c:2290
#7  0x000056081d4e63e0 in zend_call_function (fci=0x7ffd6d5c2610, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#8  0x00007f4866edfed1 in zephir_call_user_function (object_pp=0x7ffd6d5c2e00, obj_ce=0x7f48540e2c80, type=zephir_fcall_method, 
    function_name=0x7ffd6d5c2880, retval_ptr=0x0, cache_entry=0x0, cache_slot=0, param_count=1, params=0x7ffd6d5c2ed0)
    at /root/cphalcon/ext/kernel/fcall.c:385
#9  0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x0, ce=0x7f48540e2c80, type=zephir_fcall_method, object=0x7ffd6d5c2e00, 
    method_name=0x7f4867ca3e79 "fireevent", method_len=9, cache_entry=0x0, cache_slot=0, param_count=1, params=0x7ffd6d5c2ed0)
    at /root/cphalcon/ext/kernel/fcall.c:523
#10 0x00007f48672ee17e in zim_Phalcon_Mvc_Model_cloneResultMap (execute_data=0x7f488381f870, return_value=0x7ffd6d5c3660)
    at /root/cphalcon/ext/phalcon/mvc/model.zep.c:1075
#11 0x000056081d4e63e0 in zend_call_function (fci=0x7ffd6d5c3200, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#12 0x00007f4866edfed1 in zephir_call_user_function (object_pp=0x0, obj_ce=0x56081e86e950, type=zephir_fcall_ce, function_name=0x7ffd6d5c3470, 
    retval_ptr=0x7ffd6d5c3660, cache_entry=0x7ffd6d5c30c8, cache_slot=0, param_count=5, params=0x7ffd6d5c3700)
    at /root/cphalcon/ext/kernel/fcall.c:385
#13 0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x7ffd6d5c3660, ce=0x56081e86e950, type=zephir_fcall_ce, object=0x0, 
    method_name=0x7f4867d3ff0c "cloneresultmap", method_len=14, cache_entry=0x7ffd6d5c34e0, cache_slot=0, param_count=5, params=0x7ffd6d5c3700)
    at /root/cphalcon/ext/kernel/fcall.c:523
#14 0x00007f48674260bd in zim_Phalcon_Mvc_Model_Resultset_Simple_current (execute_data=0x7f488381f820, return_value=0x7f48838e6a70)
    at /root/cphalcon/ext/phalcon/mvc/model/resultset/simple.zep.c:160
#15 0x000056081d4e63e0 in zend_call_function (fci=fci@entry=0x7ffd6d5c3890, fci_cache=<optimized out>, fci_cache@entry=0x7ffd6d5c3860)
    at ./Zend/zend_execute_API.c:834
---Type <return> to continue, or q <return> to quit---bt full
#16 0x000056081d515777 in zend_call_method (object=object@entry=0x7f48838e6a48, obj_ce=<optimized out>, fn_proxy=<optimized out>, 
    function_name=function_name@entry=0x56081d5bc788 "current", function_name_len=function_name_len@entry=7, 
    retval_ptr=retval_ptr@entry=0x7f48838e6a70, param_count=0, arg1=0x0, arg2=0x0) at ./Zend/zend_interfaces.c:100
#17 0x000056081d515b49 in zend_user_it_get_current_data (_iter=0x7f48838e6a10) at ./Zend/zend_interfaces.c:178
#18 0x000056081d57f775 in ZEND_FE_FETCH_R_SPEC_VAR_HANDLER () at ./Zend/zend_vm_execute.h:16935
#19 0x000056081d5a4455 in execute_ex (ex=0x7f4883800040) at ./Zend/zend_vm_execute.h:60833
#20 0x000056081d5a81f7 in zend_execute (op_array=0x7f48540fd7e0, return_value=<optimized out>) at ./Zend/zend_vm_execute.h:63776
#21 0x00007f4866ee1048 in zephir_require_ret (return_value_ptr=0x0, 
    require_path=0x7f4854b6bdd8 "/dev/shm/tagme-stage1/tagme-pl/%%var%%www%%tagme-stage1%%releases%%20190505010437%%view%%admin%%block%%page_header.volt.php") at /root/cphalcon/ext/kernel/require.c:72
#22 0x00007f4867493cf6 in zephir_require_zval (require_path=0x7ffd6d5c3f90) at ./kernel/require.h:35
#23 0x00007f4867495ebb in zim_Phalcon_Mvc_View_Engine_Volt_render (execute_data=0x7f488381f5a0, return_value=0x7ffd6d5c42b0)
    at /root/cphalcon/ext/phalcon/mvc/view/engine/volt.zep.c:196
#24 0x000056081d4e63e0 in zend_call_function (fci=0x7ffd6d5c4310, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#25 0x00007f4866edfed1 in zephir_call_user_function (object_pp=0x7ffd6d5c4f40, obj_ce=0x56081e8c6eb0, type=zephir_fcall_method, 
    function_name=0x7ffd6d5c4580, retval_ptr=0x0, cache_entry=0x7ffd6d5c41d8, cache_slot=0, param_count=3, params=0x7ffd6d5c5050)
    at /root/cphalcon/ext/kernel/fcall.c:385
#26 0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x0, ce=0x56081e8c6eb0, type=zephir_fcall_method, object=0x7ffd6d5c4f40, 
    method_name=0x7f4867dd9ac8 "render", method_len=6, cache_entry=0x0, cache_slot=0, param_count=3, params=0x7ffd6d5c5050)
    at /root/cphalcon/ext/kernel/fcall.c:523
#27 0x00007f4867483874 in zim_Phalcon_Mvc_View__engineRender (execute_data=0x7f488381f510, return_value=0x7ffd6d5c5310)
    at /root/cphalcon/ext/phalcon/mvc/view.zep.c:1192
#28 0x000056081d4e63e0 in zend_call_function (fci=0x7ffd6d5c5370, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#29 0x00007f4866edfed1 in zephir_call_user_function (object_pp=0x7f488381f4c0, obj_ce=0x7f4854006780, type=zephir_fcall_method, 
    function_name=0x7ffd6d5c55e0, retval_ptr=0x0, cache_entry=0x7ffd6d5c5238, cache_slot=0, param_count=4, params=0x7ffd6d5c5850)
    at /root/cphalcon/ext/kernel/fcall.c:385
#30 0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x0, ce=0x7f4854006780, type=zephir_fcall_method, object=0x7f488381f4c0, 
    method_name=0x7f4867ddfd49 "_enginerender", method_len=13, cache_entry=0x0, cache_slot=0, param_count=4, params=0x7ffd6d5c5850)
    at /root/cphalcon/ext/kernel/fcall.c:523
#31 0x00007f486748c35d in zim_Phalcon_Mvc_View_partial (execute_data=0x7f488381f4a0, return_value=0x7f488381f410)
    at /root/cphalcon/ext/phalcon/mvc/view.zep.c:1864
#32 0x000056081d4e63e0 in zend_call_function (fci=0x7ffd6d5c5b60, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#33 0x00007f4866edfed1 in zephir_call_user_function (object_pp=0x7ffd6d5c6000, obj_ce=0x7f4854006780, type=zephir_fcall_method, 
---Type <return> to continue, or q <return> to quit---
    function_name=0x7ffd6d5c5dd0, retval_ptr=0x7f488381f410, cache_entry=0x7ffd6d5c5a28, cache_slot=0, param_count=2, params=0x7ffd6d5c6030)
    at /root/cphalcon/ext/kernel/fcall.c:385
#34 0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x7f488381f410, ce=0x7f4854006780, type=zephir_fcall_method, 
    object=0x7ffd6d5c6000, method_name=0x7f4867765e4c "partial", method_len=7, cache_entry=0x0, cache_slot=0, param_count=2, params=0x7ffd6d5c6030)
    at /root/cphalcon/ext/kernel/fcall.c:523
#35 0x00007f4866fd83f7 in zephir_return_call_class_method (return_value=0x7f488381f410, ce=0x7f4854006780, type=zephir_fcall_method, 
    object=0x7ffd6d5c6000, method_name=0x7f4867765e4c "partial", method_len=7, cache_entry=0x0, cache_slot=0, param_count=2, params=0x7ffd6d5c6030)
    at ./kernel/fcall.h:371
#36 0x00007f4866fd9176 in zim_Phalcon_Mvc_View_Engine_partial (execute_data=0x7f488381f440, return_value=0x7f488381f410)
    at /root/cphalcon/ext/phalcon/mvc/view/engine.zep.c:124
#37 0x000056081d5a76c1 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER () at ./Zend/zend_vm_execute.h:1032
#38 execute_ex (ex=0x7f4883800040) at ./Zend/zend_vm_execute.h:59768
#39 0x000056081d5a81f7 in zend_execute (op_array=0x7f48540fd620, return_value=<optimized out>) at ./Zend/zend_vm_execute.h:63776
#40 0x00007f4866ee1048 in zephir_require_ret (return_value_ptr=0x0, 
    require_path=0x7f4854b6c978 "/dev/shm/tagme-stage1/tagme-pl/%%var%%www%%tagme-stage1%%releases%%20190505010437%%view%%layouts%%admin_user.volt.php") at /root/cphalcon/ext/kernel/require.c:72
#41 0x00007f4867493cf6 in zephir_require_zval (require_path=0x7ffd6d5c6600) at ./kernel/require.h:35
#42 0x00007f4867495ebb in zim_Phalcon_Mvc_View_Engine_Volt_render (execute_data=0x7f488381f330, return_value=0x7ffd6d5c6920)
    at /root/cphalcon/ext/phalcon/mvc/view/engine/volt.zep.c:196
#43 0x000056081d4e63e0 in zend_call_function (fci=0x7ffd6d5c6980, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#44 0x00007f4866edfed1 in zephir_call_user_function (object_pp=0x7ffd6d5c75b0, obj_ce=0x56081e8c6eb0, type=zephir_fcall_method, 
    function_name=0x7ffd6d5c6bf0, retval_ptr=0x0, cache_entry=0x7ffd6d5c6848, cache_slot=0, param_count=3, params=0x7ffd6d5c76c0)
    at /root/cphalcon/ext/kernel/fcall.c:385
#45 0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x0, ce=0x56081e8c6eb0, type=zephir_fcall_method, object=0x7ffd6d5c75b0, 
    method_name=0x7f4867dd9ac8 "render", method_len=6, cache_entry=0x0, cache_slot=0, param_count=3, params=0x7ffd6d5c76c0)
    at /root/cphalcon/ext/kernel/fcall.c:523
#46 0x00007f4867483874 in zim_Phalcon_Mvc_View__engineRender (execute_data=0x7f488381f290, return_value=0x7ffd6d5c7990)
    at /root/cphalcon/ext/phalcon/mvc/view.zep.c:1192
#47 0x000056081d4e63e0 in zend_call_function (fci=0x7ffd6d5c79f0, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#48 0x00007f4866edfed1 in zephir_call_user_function (object_pp=0x7f488381f240, obj_ce=0x7f4854006780, type=zephir_fcall_method, 
    function_name=0x7ffd6d5c7c60, retval_ptr=0x0, cache_entry=0x7ffd6d5c78b8, cache_slot=0, param_count=5, params=0x7ffd6d5c88f0)
    at /root/cphalcon/ext/kernel/fcall.c:385
#49 0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x0, ce=0x7f4854006780, type=zephir_fcall_method, object=0x7f488381f240, 
---Type <return> to continue, or q <return> to quit---
    method_name=0x7f4867ddfd49 "_enginerender", method_len=13, cache_entry=0x0, cache_slot=0, param_count=5, params=0x7ffd6d5c88f0)
    at /root/cphalcon/ext/kernel/fcall.c:523
#50 0x00007f486748954c in zim_Phalcon_Mvc_View_render (execute_data=0x7f488381f220, return_value=0x7ffd6d5c8ba0)
    at /root/cphalcon/ext/phalcon/mvc/view.zep.c:1590
#51 0x000056081d4e63e0 in zend_call_function (fci=0x7ffd6d5c8c00, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#52 0x00007f4866edfed1 in zephir_call_user_function (object_pp=0x7ffd6d5c9ea0, obj_ce=0x7f4854006780, type=zephir_fcall_method, 
    function_name=0x7ffd6d5c8e70, retval_ptr=0x0, cache_entry=0x0, cache_slot=0, param_count=2, params=0x7ffd6d5ca1c0)
    at /root/cphalcon/ext/kernel/fcall.c:385
#53 0x00007f4866ee083f in zephir_call_class_method_aparams (return_value=0x0, ce=0x7f4854006780, type=zephir_fcall_method, object=0x7ffd6d5c9ea0, 
    method_name=0x7f4867c2ee48 "render", method_len=6, cache_entry=0x0, cache_slot=0, param_count=2, params=0x7ffd6d5ca1c0)
    at /root/cphalcon/ext/kernel/fcall.c:523
#54 0x00007f48672985ff in zim_Phalcon_Mvc_Application_handle (execute_data=0x7f488381f1d0, return_value=0x7f488381f1a0)
    at /root/cphalcon/ext/phalcon/mvc/application.zep.c:488
#55 0x000056081d5a76c1 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER () at ./Zend/zend_vm_execute.h:1032
#56 execute_ex (ex=0x7f4883800040) at ./Zend/zend_vm_execute.h:59768
#57 0x000056081d5a81f7 in zend_execute (op_array=op_array@entry=0x7f48838730e0, return_value=return_value@entry=0x7f48568fb748)
    at ./Zend/zend_vm_execute.h:63776
#58 0x000056081d4f6b72 in zend_execute_scripts (type=type@entry=8, retval=0x7f48568fb748, retval@entry=0x0, file_count=-2088636368, 
    file_count@entry=3) at ./Zend/zend.c:1498
#59 0x000056081d4926a0 in php_execute_script (primary_file=0x7ffd6d5cc850) at ./main/main.c:2594
#60 0x000056081d34279b in main (argc=<optimized out>, argv=<optimized out>) at ./sapi/fpm/fpm/fpm_main.c:1966

On this branch - https://github.com/Jurigag/zephir/tree/0.10.x

@dreamsxin

This comment has been minimized.

Copy link
Member

commented May 6, 2019

@Jurigag Use https://github.com/dreamsxin/zephir/tree/phalcon_3.4 test.
This is a modified version of Zephir 0.11.x.

@Jurigag

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

Interesting, i will test it.

@Jurigag

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

Same stack:

#0  zend_mm_alloc_small (bin_num=6, size=56, heap=0x7f66a0200040) at ./Zend/zend_alloc.c:1275
#1  _emalloc_56 () at ./Zend/zend_alloc.c:2354
#2  0x000055ba2fa05dc0 in _array_init (arg=0x7ffde1858a60, size=2) at ./Zend/zend_API.c:1090
#3  0x00007f6682cf72f4 in resolve_callable (retval=0x7ffde1858a60, type=zephir_fcall_method, ce=0x7f666f257500, object=0x7f66a021f930, 
    function=0x7ffde1858d20) at /root/cphalcon/ext/kernel/fcall.c:169
#4  0x00007f6682cf8014 in zephir_call_user_function (object_pp=0x7f66a021f930, obj_ce=0x7f666f257500, type=zephir_fcall_method, 
    function_name=0x7ffde1858d20, retval_ptr=0x0, cache_entry=0x0, cache_slot=0, param_count=0, params=0x7ffde1858ef0)
    at /root/cphalcon/ext/kernel/fcall.c:363
#5  0x00007f6682cf8bb0 in zephir_call_class_method_aparams (return_value=0x0, ce=0x7f666f257500, type=zephir_fcall_method, object=0x7f66a021f930, 
    method_name=0x7f66a02dd9a0 "afterfetch", method_len=10, cache_entry=0x0, cache_slot=0, param_count=0, params=0x7ffde1858ef0)
    at /root/cphalcon/ext/kernel/fcall.c:523
#6  0x00007f66831cf90c in zim_Phalcon_Mvc_Model_fireEvent (execute_data=0x7f66a021f910, return_value=0x7ffde1859180)
    at /root/cphalcon/ext/phalcon/mvc/model.zep.c:2621
#7  0x000055ba2f9f33e0 in zend_call_function (fci=0x7ffde18591e0, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#8  0x00007f6682cf8242 in zephir_call_user_function (object_pp=0x7ffde1859ca0, obj_ce=0x7f666f257500, type=zephir_fcall_method, 
    function_name=0x7ffde1859450, retval_ptr=0x0, cache_entry=0x0, cache_slot=0, param_count=1, params=0x7ffde1859dd0)
    at /root/cphalcon/ext/kernel/fcall.c:385
#9  0x00007f6682cf8bb0 in zephir_call_class_method_aparams (return_value=0x0, ce=0x7f666f257500, type=zephir_fcall_method, object=0x7ffde1859ca0, 
    method_name=0x7f6684389f49 "fireevent", method_len=9, cache_entry=0x0, cache_slot=0, param_count=1, params=0x7ffde1859dd0)
    at /root/cphalcon/ext/kernel/fcall.c:523
#10 0x00007f66831c02f4 in zim_Phalcon_Mvc_Model_cloneResultMap (execute_data=0x7f66a021f870, return_value=0x7ffde185a560)
    at /root/cphalcon/ext/phalcon/mvc/model.zep.c:1248
#11 0x000055ba2f9f33e0 in zend_call_function (fci=0x7ffde185a100, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:834
#12 0x00007f6682cf8242 in zephir_call_user_function (object_pp=0x0, obj_ce=0x55ba302ce160, type=zephir_fcall_ce, function_name=0x7ffde185a370, 
    retval_ptr=0x7ffde185a560, cache_entry=0x7ffde1859fc8, cache_slot=0, param_count=5, params=0x7ffde185a600)
    at /root/cphalcon/ext/kernel/fcall.c:385
#13 0x00007f6682cf8bb0 in zephir_call_class_method_aparams (return_value=0x7ffde185a560, ce=0x55ba302ce160, type=zephir_fcall_ce, object=0x0, 
    method_name=0x7f66844ca3bc "cloneresultmap", method_len=14, cache_entry=0x7ffde185a3e0, cache_slot=0, param_count=5, params=0x7ffde185a600)
    at /root/cphalcon/ext/kernel/fcall.c:523
#14 0x00007f6683374d7e in zim_Phalcon_Mvc_Model_Resultset_Simple_current (execute_data=0x7f66a021f820, return_value=0x7f666f489370)
    at /root/cphalcon/ext/phalcon/mvc/model/resultset/simple.zep.c:160
#15 0x000055ba2f9f33e0 in zend_call_function (fci=fci@entry=0x7ffde185a790, fci_cache=<optimized out>, fci_cache@entry=0x7ffde185a760)
    at ./Zend/zend_execute_API.c:834

Just to make sure on this branch above i had the same after adding this fix - so i guess it somehow broke this code - not sure how, and why. Maybe we should also change SEPARATE_ARRAY which is called in fcall.c:425 to the code from your PR?

@Jurigag

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

Well i changed this to code from your PR and have different seg fault so i guess that's not it.

@dreamsxin

This comment has been minimized.

Copy link
Member

commented May 6, 2019

Can you give me a code that can reproduce the error?

@Jurigag

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

I would need to reproduce it without phalcon first. Will try to do it in few days.

zsilbi pushed a commit to zsilbi/cphalcon that referenced this issue May 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.