Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon CLI crashes PHP randomly

Hello Phalconers

I'm having some trouble with a PHP CLI script running as a nohup script. The script crashes randomly i cannot find its root cause.

Do any of you guys have an idea, what the problem could be?

Nohup command: nohup php /var/www/path/to/script/cli.php > EmailHandler.out 2>&1 &

Platform: Ubuntu 14.04.3 LTS

PHP Version: PHP 5.6.18-1+deb.sury.org~trusty+1

Phalcon version: 2.0.9

Error generated:

./apport.log.1:ERROR: apport (pid 15519) Sun Apr 10 05:30:51 2016: called for pid 962, signal 11, core limit 0 ./apport.log.1:ERROR: apport (pid 15519) Sun Apr 10 05:30:51 2016: executable: /usr/bin/php5 (command line "php /var/path/to/email/cli.php") ./apport.log.1:ERROR: apport (pid 15519) Sun Apr 10 05:30:51 2016: isclosingsession(): no DBUSSESSIONBUSADDRESS in environment ./apport.log.1:ERROR: apport (pid 15519) Sun Apr 10 05:31:01 2016: wrote report /var/crash/usrbinphp5.0.crash

edited Apr '16

You have crash:

/var/crash/_usrbinphp5.0.crash

If you don't have installed gdb then install it. And then write:

gdb php /var/crash/_usrbinphp5.0.crash

Then write bt and post here log from it.

edited Apr '16

When i do following it doesn't recognize the file format:

gdb php /var/crash/usrbin_php5.0.crash

output:

Reading symbols from php...(no debugging symbols found)...done. "/var/crash/usrbin_php5.0.crash" is not a core dump: File format not recognized (gdb) bt No stack.

You'll need proper debugging symbols set up. Check this SO thread: http://askubuntu.com/questions/13205/debugging-php-with-gdb

edited Apr '16

Well there should be a dump but there isn't one. Try to write ulimit -c unlimited and then wait again for this error.

Ran it through GDB and received this segmentation fault:

Program received signal SIGSEGV, Segmentation fault. 0x000000000069d966 in phpsockopread (stream=0x7ffff7fe26f0, buf=0x7ffff7fe26c0 "\024restaurantmailQueue\rexecut", count=28) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/main/streams/xpsocket.c:145 145 /build/php5-6hC5Fj/php5-5.6.20+dfsg/main/streams/xp_socket.c: No such file or directory.

edited Apr '16

I fixed the error but now i'm receiving this error:

Program received signal SIGSEGV, Segmentation fault. 0x0000000000626412 in phptrim (c=0x7ffff7fe0a50 "restaurantmailQueue.executionTime", len=34, what=<optimized out>, whatlen=<optimized out>, returnvalue=<optimized out>, mode=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/ext/standard/string.c:831 831 in /build/php5-6hC5Fj/php5-5.6.20+dfsg/ext/standard/string.c

Backtrace:

#0  0x0000000000626412 in php_trim (c=0x7ffff7fdc720 "restaurant_mailQueue.executionTime", len=34, what=<optimized out>, what_len=<optimized out>, return_value=<optimized out>, mode=<optimized out>)
    at /build/php5-6hC5Fj/php5-5.6.20+dfsg/ext/standard/string.c:831
#1  0x00007fffed200a68 in zephir_fast_trim () from /usr/lib/php5/20131226/phalcon.so
#2  0x00007fffed405b0d in zim_Phalcon_Db_Dialect_escape () from /usr/lib/php5/20131226/phalcon.so
#3  0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#4  0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#5  0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#6  0x00007fffed2da6d6 in zim_Phalcon_Db_Dialect_prepareQualified () from /usr/lib/php5/20131226/phalcon.so
#7  0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#8  0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#9  0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#10 0x00007fffed26dbd2 in zim_Phalcon_Db_Dialect_getSqlExpressionQualified () from /usr/lib/php5/20131226/phalcon.so
#11 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#12 0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#13 0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#14 0x00007fffed307566 in zim_Phalcon_Db_Dialect_getSqlExpression () from /usr/lib/php5/20131226/phalcon.so
#15 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#16 0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#17 0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#18 0x00007fffed2d5dbb in zim_Phalcon_Db_Dialect_getSqlExpressionBinaryOperations () from /usr/lib/php5/20131226/phalcon.so
#19 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#20 0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#21 0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#22 0x00007fffed307d13 in zim_Phalcon_Db_Dialect_getSqlExpression () from /usr/lib/php5/20131226/phalcon.so
#23 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#24 0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#25 0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#26 0x00007fffed2d5dbb in zim_Phalcon_Db_Dialect_getSqlExpressionBinaryOperations () from /usr/lib/php5/20131226/phalcon.so
#27 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#28 0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#29 0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#30 0x00007fffed307d13 in zim_Phalcon_Db_Dialect_getSqlExpression () from /usr/lib/php5/20131226/phalcon.so
#31 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#32 0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#33 0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#34 0x00007fffed2d5cfa in zim_Phalcon_Db_Dialect_getSqlExpressionBinaryOperations () from /usr/lib/php5/20131226/phalcon.so
#35 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#36 0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so

Looks like some problem with your query, using Page Down you can scroll back trace and figure out which your instruction it's causing it. Can you post it ?

edited Apr '16

This is the end of the backtrace, its a script running within the nohup program, and is iterating thousands of times :)

68115 0x0000000000780e47 in zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:592
#68116 0x0000000000716478 in execute_ex (execute_data=0x7ffff7faa3a0) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:363
#68117 0x00000000006cb3a9 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:73
#68118 0x0000000000780e47 in zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:592
#68119 0x0000000000716478 in execute_ex (execute_data=0x7ffff7fa9b90) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:363
#68120 0x00000000006cb3a9 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:73
#68121 0x0000000000780e47 in zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:592
#68122 0x0000000000716478 in execute_ex (execute_data=0x7ffff7fa9380) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:363
#68123 0x00000000006cb3a9 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:73
#68124 0x0000000000780e47 in zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:592
#68125 0x0000000000716478 in execute_ex (execute_data=0x7ffff7fa8b70) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:363
#68126 0x00000000006cb3a9 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:73
#68127 0x0000000000780e47 in zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:592
#68128 0x0000000000716478 in execute_ex (execute_data=0x7ffff7fa8360) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:363
#68129 0x00000000006cb3a9 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:73
#68130 0x00000000006cd0d3 in zend_call_function (fci=0x7fffffffa520, fci_cache=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_execute_API.c:829
#68131 0x00007fffed200d7d in zephir_call_user_func_array_noex () from /usr/lib/php5/20131226/phalcon.so
#68132 0x00007fffed4ae3ff in zim_Phalcon_Dispatcher_dispatch () from /usr/lib/php5/20131226/phalcon.so
---Type <return> to continue, or q <return> to quit---
#68133 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#68134 0x00007fffed20b0e1 in zephir_call_user_function () from /usr/lib/php5/20131226/phalcon.so
#68135 0x00007fffed221a2f in zephir_call_class_method_aparams () from /usr/lib/php5/20131226/phalcon.so
#68136 0x00007fffed3f91fb in zim_Phalcon_Cli_Console_handle () from /usr/lib/php5/20131226/phalcon.so
#68137 0x00000000006cb4ab in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:97
#68138 0x0000000000780924 in zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:560
#68139 0x0000000000716478 in execute_ex (execute_data=0x7ffff7fa7b90) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_vm_execute.h:363
#68140 0x00000000006cb3a9 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend_dtrace.c:73
#68141 0x00000000006dd750 in zend_execute_scripts ([email protected]=8, [email protected]=0x0, [email protected]=3) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/Zend/zend.c:1341
#68142 0x000000000067b8c2 in php_execute_script ([email protected]=0x7fffffffd250) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/main/main.c:2613
#68143 0x000000000078279e in do_cli (argc=2, argv=0xe94910) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/sapi/cli/php_cli.c:994
#68144 0x00000000004629c0 in main (argc=2, argv=0xe94910) at /build/php5-6hC5Fj/php5-5.6.20+dfsg/sapi/cli/php_cli.c:1378

Any ideas guys?



106.9k
Accepted
answer

As you see it crashes somwhere on some query. I would create issue on github.