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

swoole开启buffer 偶现core dump #313

Open
Dreamred opened this issue Mar 10, 2022 · 3 comments
Open

swoole开启buffer 偶现core dump #313

Dreamred opened this issue Mar 10, 2022 · 3 comments
Assignees
Labels

Comments

@Dreamred
Copy link

swoole4.3.6 php7.2.34 SeasLog2.0.2

core dump堆栈:

#0  zend_string_copy (s=0x7f2900001407)
    at /usr/local/php/include/php/Zend/zend_string.h:186
#1  _zval_get_string (op=0x7f29fc506ca8)
    at /usr/local/php/include/php/Zend/zend_operators.h:273
#2  real_php_log_buffer (opt_len=<optimized out>, opt=<optimized out>, 
    msg_buffer=0x7f29fc50eaa0) at /demo/SeasLog-master/src/Buffer.c:93
#3  seaslog_shutdown_buffer (re_init=1)
    at /demo/SeasLog-master/src/Buffer.c:218
#4  seaslog_shutdown_buffer (re_init=1)
    at /demo/SeasLog-master/src/Buffer.c:194
#5  0x00007f29fc7370da in seaslog_buffer_set (
    log_info=log_info@entry=0x7f29fc52eee0 "40:12|jfezdjc5cuhjo6wuaavd|code:0\n", log_info_len=log_info_len@entry=49, 
    path=path@entry=0x7f29fc501f50 "/home/wwwlogs/2022031014.INFO.log", 
    path_len=path_len@entry=39, ce=ce@entry=0x5585154ce730)
    at /demo/SeasLog-master/src/Buffer.c:187
#6  0x00007f29fc735a89 in seaslog_real_buffer_log_ex (ce=0x5585154ce730, 
    log_file_path_len=39, 
    log_file_path=0x7f29fc501f50 "/home/wwwlogs/2022031014.INFO.log", 
    message_len=49, 
    message=0x7f29fc52eee0 "40:12|jfezdjc5cuhjo6wuaavd|code:0\n") at /demo/SeasLog-master/src/Appender.c:93
#7  appender_handle_file (message_len=<optimized out>, level_int=-61673760, 
    logger=<optimized out>, ce=0x5585154ce730, 
    level=0x27 <error: Cannot access memory at address 0x27>, 
    message=<optimized out>) at /demo/SeasLog-master/src/Appender.c:146
#8  seaslog_log_ex (argc=argc@entry=1, 
    level=level@entry=0x7f29fc739065 "INFO", level_int=level_int@entry=6, 
    message=<optimized out>, message_len=<optimized out>, 
    module=module@entry=0x7f29fc73a203 "", module_len=0, ce=0x5585154ce730)
    at /demo/SeasLog-master/src/Appender.c:190
#9  0x00007f29fc732319 in seaslog_log_context_ex (check_argc=1, context=0x0, 
--Type <RET> for more, q to quit, c to continue without paging--
    module=<optimized out>, module_len=<optimized out>, 
    seaslog_ce=0x5585154ce730, message_len=<optimized out>, 
    message=<optimized out>, level_int=6, level=0x7f29fc739065 "INFO", 
    argc=1) at /demo/SeasLog-master/seaslog.c:378
#10 seaslog_log_context_ex (seaslog_ce=0x5585154ce730, 
    module_len=<optimized out>, module=<optimized out>, context=0x0, 
    message_len=<optimized out>, message=<optimized out>, level_int=6, 
    level=0x7f29fc739065 "INFO", check_argc=1, argc=1)
    at /demo/SeasLog-master/seaslog.c:367
#11 seaslog_log_by_level_common_ex (seaslog_ce=<optimized out>, 
    logger_len=<optimized out>, logger_str=<optimized out>, context=0x0, 
    messages=<optimized out>, level_int=6, level=0x7f29fc739065 "INFO", 
    check_argc=1, argc=1) at /demo/SeasLog-master/seaslog.c:418
#12 seaslog_log_by_level_common (level=0x7f29fc739065 "INFO", level_int=6, 
    return_value=<optimized out>, execute_data=<optimized out>)
    at /demo/SeasLog-master/seaslog.c:509
#13 0x0000558512c64144 in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER ()
    at /demo/lnmp1.7/src/php-7.2.34/Zend/zend_vm_execute.h:911
#14 execute_ex (ex=0x558515c039e8)
    at /demo/lnmp1.7/src/php-7.2.34/Zend/zend_vm_execute.h:59793
#15 0x00007f29fbd415de in swoole::PHPCoroutine::create_func (
    arg=<optimized out>)
    at /demo/swoole-src-4.3.6/swoole_coroutine.cc:369
#16 0x00007f29fbcf8d8f in swoole::Context::context_func (arg=0x558515c039e8)
    at /demo/swoole-src-4.3.6/src/coroutine/context.cc:120
#17 0x00007f29fbdb8431 in make_fcontext ()
    at /demo/swoole-src-4.3.6/thirdparty/boost/asm/make_x86_64_sysv_elf_gas.S:64
#18 0x0000000000000000 in ?? ()

@Rock-Lee-520
Copy link
Member

swoole4.3.6 php7.2.34 SeasLog2.0.2

core dump堆栈:

#0  zend_string_copy (s=0x7f2900001407)
    at /usr/local/php/include/php/Zend/zend_string.h:186
#1  _zval_get_string (op=0x7f29fc506ca8)
    at /usr/local/php/include/php/Zend/zend_operators.h:273
#2  real_php_log_buffer (opt_len=<optimized out>, opt=<optimized out>, 
    msg_buffer=0x7f29fc50eaa0) at /demo/SeasLog-master/src/Buffer.c:93
#3  seaslog_shutdown_buffer (re_init=1)
    at /demo/SeasLog-master/src/Buffer.c:218
#4  seaslog_shutdown_buffer (re_init=1)
    at /demo/SeasLog-master/src/Buffer.c:194
#5  0x00007f29fc7370da in seaslog_buffer_set (
    log_info=log_info@entry=0x7f29fc52eee0 "40:12|jfezdjc5cuhjo6wuaavd|code:0\n", log_info_len=log_info_len@entry=49, 
    path=path@entry=0x7f29fc501f50 "/home/wwwlogs/2022031014.INFO.log", 
    path_len=path_len@entry=39, ce=ce@entry=0x5585154ce730)
    at /demo/SeasLog-master/src/Buffer.c:187
#6  0x00007f29fc735a89 in seaslog_real_buffer_log_ex (ce=0x5585154ce730, 
    log_file_path_len=39, 
    log_file_path=0x7f29fc501f50 "/home/wwwlogs/2022031014.INFO.log", 
    message_len=49, 
    message=0x7f29fc52eee0 "40:12|jfezdjc5cuhjo6wuaavd|code:0\n") at /demo/SeasLog-master/src/Appender.c:93
#7  appender_handle_file (message_len=<optimized out>, level_int=-61673760, 
    logger=<optimized out>, ce=0x5585154ce730, 
    level=0x27 <error: Cannot access memory at address 0x27>, 
    message=<optimized out>) at /demo/SeasLog-master/src/Appender.c:146
#8  seaslog_log_ex (argc=argc@entry=1, 
    level=level@entry=0x7f29fc739065 "INFO", level_int=level_int@entry=6, 
    message=<optimized out>, message_len=<optimized out>, 
    module=module@entry=0x7f29fc73a203 "", module_len=0, ce=0x5585154ce730)
    at /demo/SeasLog-master/src/Appender.c:190
#9  0x00007f29fc732319 in seaslog_log_context_ex (check_argc=1, context=0x0, 
--Type <RET> for more, q to quit, c to continue without paging--
    module=<optimized out>, module_len=<optimized out>, 
    seaslog_ce=0x5585154ce730, message_len=<optimized out>, 
    message=<optimized out>, level_int=6, level=0x7f29fc739065 "INFO", 
    argc=1) at /demo/SeasLog-master/seaslog.c:378
#10 seaslog_log_context_ex (seaslog_ce=0x5585154ce730, 
    module_len=<optimized out>, module=<optimized out>, context=0x0, 
    message_len=<optimized out>, message=<optimized out>, level_int=6, 
    level=0x7f29fc739065 "INFO", check_argc=1, argc=1)
    at /demo/SeasLog-master/seaslog.c:367
#11 seaslog_log_by_level_common_ex (seaslog_ce=<optimized out>, 
    logger_len=<optimized out>, logger_str=<optimized out>, context=0x0, 
    messages=<optimized out>, level_int=6, level=0x7f29fc739065 "INFO", 
    check_argc=1, argc=1) at /demo/SeasLog-master/seaslog.c:418
#12 seaslog_log_by_level_common (level=0x7f29fc739065 "INFO", level_int=6, 
    return_value=<optimized out>, execute_data=<optimized out>)
    at /demo/SeasLog-master/seaslog.c:509
#13 0x0000558512c64144 in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER ()
    at /demo/lnmp1.7/src/php-7.2.34/Zend/zend_vm_execute.h:911
#14 execute_ex (ex=0x558515c039e8)
    at /demo/lnmp1.7/src/php-7.2.34/Zend/zend_vm_execute.h:59793
#15 0x00007f29fbd415de in swoole::PHPCoroutine::create_func (
    arg=<optimized out>)
    at /demo/swoole-src-4.3.6/swoole_coroutine.cc:369
#16 0x00007f29fbcf8d8f in swoole::Context::context_func (arg=0x558515c039e8)
    at /demo/swoole-src-4.3.6/src/coroutine/context.cc:120
#17 0x00007f29fbdb8431 in make_fcontext ()
    at /demo/swoole-src-4.3.6/thirdparty/boost/asm/make_x86_64_sysv_elf_gas.S:64
#18 0x0000000000000000 in ?? ()

可以提供一下复现的方式么?

@Neeke
Copy link
Member

Neeke commented May 11, 2022

@Dreamred 可以提供复现脚本么

@Dreamred
Copy link
Author

复现代码:

<?php

use Swoole\Runtime;

$server = new Swoole\Http\Server("127.0.0.1", 9501, SWOOLE_PROCESS,SWOOLE_SOCK_TCP);
$server->set([
  	'worker_num'	=>  2
]);
// 不开启协程就无事发生
Runtime::enableCoroutine();

$server->on('request', function ($request, $response) {
    \Seaslog::info('something');
    $response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>");
});

$server->start();

复现方式:
ab -k -n 10000 -c 100 http://127.0.0.1:9501/

环境补充:
Linux ubuntu 5.13.0-37-generic #42~20.04.1-Ubuntu SMP Tue Mar 15 15:44:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 43 bits physical, 48 bits virtual
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1

SeasLog配置:
;是否以目录区分Logger 1是(默认) 0否
seaslog.disting_folder = 1

;是否以type分文件 1是 0否(默认)
seaslog.disting_type = 1

;是否每小时划分一个文件 1是 0否(默认)
seaslog.disting_by_hour = 1

;是否启用buffer 1是 0否(默认)
seaslog.use_buffer = 1

;buffer中缓冲数量 默认0(不使用buffer_size)
seaslog.buffer_size = 100

;cli运行时关闭buffer
;1是 0否(默认)
seaslog.buffer_disabled_in_cli = 0

@Neeke @rock-liyi

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

No branches or pull requests

3 participants