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

Connection reset when DI has more than 10 arguments #12299

Closed
Zaszczyk opened this issue Oct 7, 2016 · 10 comments
Closed

Connection reset when DI has more than 10 arguments #12299

Zaszczyk opened this issue Oct 7, 2016 · 10 comments
Assignees
Labels
bug A bug report status: medium Medium
Milestone

Comments

@Zaszczyk
Copy link
Contributor

Zaszczyk commented Oct 7, 2016

I create service in DI:

$di->setShared('Company\TariffService', [
    'className' => 'XXX\Models\Services\Service\Company\TariffService',
    'arguments' => [
        [
            'type' => 'service',
            'name' => 'Company\TariffRepository',
        ],
        ...
    ]
]);

It works perfect until I set 11 arguments, it such situation I got Connection Reset/ERR_EMPTY_RESPONSE. I got errors only when call this service:
$this->getDI()->get('Company\TariffService');
How can I debug it?

PHP 5.6
Phalcon 2.1.x
Ubuntu 14.04

@Jurigag
Copy link
Contributor

Jurigag commented Oct 7, 2016

If using php-fpm(possibly you need to source something too like in apache below).

apt-get install gdb
service stop php5-fpm/php7.0-fpm(or whatver other name)
gdb php5-fpm/php7.0-fpm
// run -X, not sure if it's needed or not

if you are using apache2 php handler:

service apache2 stop
source /etc/apache2/envvars
gdb apache2
run -X

refresh your browser
it should tell you in gdb that execution stoped unexpectedly or something, write bt and post result of it here

Connection reset most likely means seg fault or something similar, if this don't work then just check https://bugs.php.net/bugs-generating-backtrace.php here to how generate backtrace.

Also you possibly have already somewhere core dump. Then just do gdb <whatever process regenreated it> <path to core dump> and write bt

@Zaszczyk
Copy link
Contributor Author

Zaszczyk commented Oct 9, 2016

Backtrace:

#0  0x00007ffff3ce309d in zend_hash_get_current_data_ex () from /usr/lib/apache2/modules/libphp5.so
#1  0x00007fffe1ef3ce3 in zephir_create_instance_params.isra () from /usr/lib/php5/20131226/phalcon.so
#2  0x00007fffe1fe3e3e in zim_Phalcon_Di_Service_Builder_build () from /usr/lib/php5/20131226/phalcon.so
#3  0x00007ffff3cc3b0b in dtrace_execute_internal () from /usr/lib/apache2/modules/libphp5.so
#4  0x00007fffe1ecc73f in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#5  0x00007fffe1ee369f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#6  0x00007fffe2094f3e in zim_Phalcon_Di_Service_resolve () from /usr/lib/php5/20131226/phalcon.so
#7  0x00007ffff3cc3b0b in dtrace_execute_internal () from /usr/lib/apache2/modules/libphp5.so
#8  0x00007fffe1ecc73f in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#9  0x00007fffe1ee369f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#10 0x00007fffe206999c in zim_Phalcon_Di_get () from /usr/lib/php5/20131226/phalcon.so
#11 0x00007ffff3cc3b0b in dtrace_execute_internal () from /usr/lib/apache2/modules/libphp5.so
#12 0x00007ffff3d79554 in ?? () from /usr/lib/apache2/modules/libphp5.so
#13 0x00007ffff3d0eb08 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#14 0x00007ffff3cc3a09 in dtrace_execute_ex () from /usr/lib/apache2/modules/libphp5.so

@sergeyklay
Copy link
Contributor

The 2.1.x branch is not longer supported. Could you please try v3?

@Zaszczyk
Copy link
Contributor Author

Zaszczyk commented Oct 9, 2016

@sergeyklay @Jurigag ok, it works on v3 and PHP7. I created repo to reproduce this error: https://github.com/Zaszczyk/vokuro. It is needed to run indexAction in indexController.

@stamster
Copy link
Contributor

stamster commented Oct 9, 2016

https://github.com/phalcon/cphalcon/releases is your (everyone's) friend.

@Zaszczyk
Copy link
Contributor Author

Zaszczyk commented Oct 11, 2016

@Jurigag @sergeyklay i'm sorry but something in the air. I came back to this task and switched to machine with PHP7 and got same error this time. So I executed Jurigag's procedure and got:

(gdb) run -X
Starting program: /usr/sbin/apache2 -X
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007fffde91eda8 in ?? ()
(gdb) bt
#0  0x00007fffde91eda8 in ?? ()
#1  0x00007fffffff93e8 in ?? ()
#2  0x00000000000000b9 in ?? ()
#3  0x0000000000000002 in ?? ()
#4  0x00007fffffff9650 in ?? ()
#5  0x0000000000000000 in ?? ()
(gdb) bt full
#0  0x00007fffde91eda8 in ?? ()
No symbol table info available.
#1  0x00007fffffff93e8 in ?? ()
No symbol table info available.
#2  0x00000000000000b9 in ?? ()
No symbol table info available.
#3  0x0000000000000002 in ?? ()
No symbol table info available.
#4  0x00007fffffff9650 in ?? ()
No symbol table info available.
#5  0x0000000000000000 in ?? ()
No symbol table info available.

PHP 7.0.11-1+deb.sury.orgtrusty+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.11-1+deb.sury.org
trusty+1, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
Phalcon: 3.0.1
Edit:

[Tue Oct 11 15:40:56.676088 2016] [core:notice] [pid 2775] AH00051: child pid 2784 exit signal Segmentation fault (11), possible coredump in /etc/apache2

@Jurigag
Copy link
Contributor

Jurigag commented Oct 11, 2016

This certain stack is totally useless.

@Jurigag
Copy link
Contributor

Jurigag commented Oct 13, 2016

Well on php 7 i couldn't manage to get any stacktrace which could tell anything. On php 5.6 there is this:

#0  0x00000000009ed4d3 in _zend_is_inconsistent (ht=0x29, 
    file=0xfcc038 "/root/.phpbrew/build/5.6.19-debug/Zend/zend_hash.c", line=1044)
    at /root/.phpbrew/build/5.6.19-debug/Zend/zend_hash.c:60
#1  0x00000000009f0541 in zend_hash_move_forward_ex (ht=0x29, pos=0x7fffffff9b58)
    at /root/.phpbrew/build/5.6.19-debug/Zend/zend_hash.c:1044
#2  0x00007fffe98c3ee8 in zephir_create_instance_params (return_value=0x7ffff7e23bb8, class_name=0x7ffff7fce3e8, 
    params=0x7ffff7e24258) at /root/2.1.x-orig/ext/kernel/object.c:1566
#3  0x00007fffe9a9630b in zim_Phalcon_Di_Service_Builder_build (ht=3, return_value=0x7ffff7e23940, 
    return_value_ptr=0x7fffffffa2e0, this_ptr=0x7ffff7e23a58, return_value_used=1)
    at /root/2.1.x-orig/ext/phalcon/di/service/builder.zep.c:244
#4  0x00007fffe98d5a43 in zephir_call_function_opt (fci=0x7fffffffa0e0, fci_cache=0x7fffffffa0b0, info=0x7fffffffa210)
    at /root/2.1.x-orig/ext/kernel/extended/fcall.c:1319
#5  0x00007fffe98cf61f in zephir_call_user_function (object_pp=0x7fffffffa1c0, obj_ce=0x16ad5f0, 
    type=zephir_fcall_method, function_name=0x0, retval_ptr_ptr=0x7fffffffa2e0, cache_entry=0x0, cache_slot=180, 
    param_count=3, params=0x7fffffffa350, info=0x7fffffffa210) at /root/2.1.x-orig/ext/kernel/fcall.c:570
#6  0x00007fffe98cfddb in zephir_call_class_method_aparams (return_value_ptr=0x7fffffffa2e0, ce=0x16ad5f0, 
    type=zephir_fcall_method, object=0x7ffff7e23a58, method_name=0x7fffea19c6b0 "build", method_len=5, cache_entry=0x0, 
    cache_slot=180, param_count=3, params=0x7fffffffa350) at /root/2.1.x-orig/ext/kernel/fcall.c:824
#7  0x00007fffe9a935f0 in zim_Phalcon_Di_Service_resolve (ht=2, return_value=0x7ffff7e233f0, 
    return_value_ptr=0x7fffffffa800, this_ptr=0x7ffff7e1e5b0, return_value_used=1)
    at /root/2.1.x-orig/ext/phalcon/di/service.zep.c:278
#8  0x00007fffe98d5a43 in zephir_call_function_opt (fci=0x7fffffffa5f0, fci_cache=0x7fffffffa5c0, info=0x7fffffffa720)
    at /root/2.1.x-orig/ext/kernel/extended/fcall.c:1319
#9  0x00007fffe98cf61f in zephir_call_user_function (object_pp=0x7fffffffa6d0, obj_ce=0x16abe10, 
    type=zephir_fcall_method, function_name=0x0, retval_ptr_ptr=0x7fffffffa800, cache_entry=0x0, cache_slot=0, 
    param_count=2, params=0x7fffffffa8a0, info=0x7fffffffa720) at /root/2.1.x-orig/ext/kernel/fcall.c:570
#10 0x00007fffe98cfddb in zephir_call_class_method_aparams (return_value_ptr=0x7fffffffa800, ce=0x16abe10, 
    type=zephir_fcall_method, object=0x7ffff7e1e5b0, method_name=0x7fffe9e63117 "resolve", method_len=7, 
    cache_entry=0x0, cache_slot=0, param_count=2, params=0x7fffffffa8a0) at /root/2.1.x-orig/ext/kernel/fcall.c:824
---Type <return> to continue, or q <return> to quit---
#11 0x00007fffe994d1e6 in zim_Phalcon_Di_get (ht=1, return_value=0x7ffff7e238c8, return_value_ptr=0x7ffff7f96200, 
    this_ptr=0x7ffff7fccf88, return_value_used=1) at /root/2.1.x-orig/ext/phalcon/di.zep.c:458
#12 0x0000000000a22635 in zend_do_fcall_common_helper_SPEC (execute_data=0x7ffff7f96eb8)
    at /root/.phpbrew/build/5.6.19-debug/Zend/zend_vm_execute.h:558
#13 0x0000000000a22e06 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER (execute_data=0x7ffff7f96eb8)
    at /root/.phpbrew/build/5.6.19-debug/Zend/zend_vm_execute.h:693
#14 0x0000000000a21ca4 in execute_ex (execute_data=0x7ffff7f96eb8)
    at /root/.phpbrew/build/5.6.19-debug/Zend/zend_vm_execute.h:363
#15 0x0000000000a21d2d in zend_execute (op_array=0x7ffff7fcdf20)
    at /root/.phpbrew/build/5.6.19-debug/Zend/zend_vm_execute.h:388
#16 0x00000000009dd0a2 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /root/.phpbrew/build/5.6.19-debug/Zend/zend.c:1341
#17 0x000000000094314b in php_execute_script (primary_file=0x7fffffffced0)
    at /root/.phpbrew/build/5.6.19-debug/main/main.c:2610
#18 0x0000000000a9070b in do_cli (argc=2, argv=0x1340f30) at /root/.phpbrew/build/5.6.19-debug/sapi/cli/php_cli.c:994
#19 0x0000000000a91a39 in main (argc=2, argv=0x1340f30) at /root/.phpbrew/build/5.6.19-debug/sapi/cli/php_cli.c:1378

@andresgutierrez any idea ? I will try to reproduce a problem in zephir only.

@sergeyklay sergeyklay added this to the 3.0.3 milestone Oct 14, 2016
@sergeyklay sergeyklay self-assigned this Oct 14, 2016
@sergeyklay sergeyklay modified the milestones: 3.0.3, 3.0.4 Dec 24, 2016
@sergeyklay sergeyklay removed this from the 3.0.4 milestone Jan 12, 2017
@sergeyklay sergeyklay modified the milestones: 3.2.0, 3.1.x Mar 15, 2017
@sergeyklay sergeyklay modified the milestones: 3.1.x, 3.1.1 Mar 23, 2017
@sergeyklay sergeyklay modified the milestones: 3.1.1, 3.2.x Apr 5, 2017
@sergeyklay
Copy link
Contributor

@Zaszczyk Could you please try now by using latest Zephir:

git clone git@github.com:phalcon/cphalcon.git
cd cphalcon
git checkout 3.1.x # or 3.2.x

zephir fullclean
zephir build

@Jurigag
Copy link
Contributor

Jurigag commented Apr 14, 2017

@Zaszczyk yea i was writing him that this was fixed, i thing it can be closed

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

5 participants