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

Program terminated with signal SIGSEGV, Segmentation fault. #514

Closed
github-zjh opened this issue Sep 22, 2020 · 3 comments
Closed

Program terminated with signal SIGSEGV, Segmentation fault. #514

github-zjh opened this issue Sep 22, 2020 · 3 comments

Comments

@github-zjh
Copy link

github-zjh commented Sep 22, 2020

@鸟哥, 最近用yaf:3.2.5, cli下, 偶尔会出现core dumped. 分析了core文件, 帮忙看下是什么问题
gdb如下:

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x000055b3213b4e5a in zend_gc_collect_cycles ()
#2  0x000055b3213b3e08 in ?? ()
#3  0x000055b321410a91 in execute_ex ()
#4  0x00007fbf98a43c4b in yaf_do_call_user_method (ret=0x7ffcfb1054a0, fbc=<optimized out>, call=0x7fbf98814410) at /tmp/pear/temp/yaf/yaf.c:223
#5  yaf_call_user_method_with_0_arguments (obj=0x7fbf98881f60, fbc=fbc@entry=0x7fbf9880c260, ret=0x7ffcfb1054a0, ret@entry=0x7fbf9890ef00) at /tmp/pear/temp/yaf/yaf.c:308
#6  0x00007fbf98a44833 in yaf_controller_execute (ret=0x7fbf9890ef00, args=0x0, count=<optimized out>, func=0x7fbf9880c260, ctl=0x7ffcfb105490) at /tmp/pear/temp/yaf/yaf_controller.h:67
#7  yaf_dispatcher_handle (dispatcher=dispatcher@entry=0x7fbf9888b000) at /tmp/pear/temp/yaf/yaf_dispatcher.c:629
#8  0x00007fbf98a453a7 in yaf_dispatcher_dispatch (dispatcher=0x7fbf9888b000) at /tmp/pear/temp/yaf/yaf_dispatcher.c:796
#9  0x00007fbf98a4a879 in zim_yaf_dispatcher_dispatch (execute_data=<optimized out>, return_value=0x7ffcfb1055c0) at /tmp/pear/temp/yaf/yaf_dispatcher.c:833
#10 0x000055b3214140e8 in execute_ex ()
#11 0x000055b321414cf3 in zend_execute ()
#12 0x000055b32138f6b3 in zend_execute_scripts ()
#13 0x000055b32132f600 in php_execute_script ()
#14 0x000055b321416dd6 in ?? ()
#15 0x000055b3210cc64b in ?? ()
#16 0x00007fbf9b8bd09b in __libc_start_main (main=0x55b3210cc200, argc=4, argv=0x7ffcfb108f58, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffcfb108f48)
    at ../csu/libc-start.c:308
#17 0x000055b3210ccd8a in _start ()

程序代码:

/**
 * 日志收集处理
 *
 */
class CollectionController extends BaseCliController
{
    /**
     * 开启日志队列消费
     *
     * `php public\console "cli/collection/consume" "queue_name=application" `
     */
    public function consumeAction()
    {
        /**
         * @var \Yaf_Request_Simple $request
         */
        $request = $this->getRequest();
        $queue_name = $request->get('queue_name');
        if ($queue_name) {
            self::collection($queue_name); //内部实现是死循环,每次sleep 10秒
        }
    }
   ....
}

CLI下常驻进程在跑,偶尔会crashed退出。

php public/console cli/collection/consume "queue_name=log_queue_message"

文件console.php

#!/usr/bin/env php
<?php declare(strict_types=1);
define('APPLICATION_PATH', dirname(dirname(__FILE__)));
define('APPLICATION_ENV', ini_get('yaf.environ'));
$app = new \Yaf_Application(APPLICATION_PATH . '/conf/application.' . APPLICATION_ENV . '.ini');
// 开启异常抛出,并以CLI模式接收请求
$request_uri  = $_SERVER['argv'][1] ?? '';
$request_http = new \Yaf_Request_Http($request_uri, '');
if (isset($_SERVER['argv'][2]) && $query = $_SERVER['argv'][2]) {
    $queryParts = explode('&', $query);
    $params     = [];
    foreach ($queryParts as $param) {
        list($key, $value) = explode('=', $param);
        $request_http->setParam($key, $value);
    }
}
// 启动 (自动加载)
$app->bootstrap();
$app->getDispatcher()->throwException(true)->catchException(false)->dispatch($request_http);

@laruence
Copy link
Owner

laruence commented Jan 5, 2021

你能打包一个可重现的脚本集合给我么?

@laruence
Copy link
Owner

laruence commented Jan 5, 2021

另外,PHP是什么版本?

@github-zjh
Copy link
Author

另外,PHP是什么版本?

PHP 7.4.10 (cli) (built: Sep 1 2020 13:58:08) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

后来监控其他错误日志,是程序内部报错导致的crashed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants