swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.25k stars 3.16k forks source link

A bug occurred in Swoole-v5.1.1, please report it. #5306

Open fpysky opened 3 weeks ago

fpysky commented 3 weeks ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error. [2024-04-26 10:18:00 $32504.0] WARNING Server::check_worker_exit_status(): worker(pid=33336, id=12) abnormal exit, status=0, signal=11 A bug occurred in Swoole-v5.1.1, please report it. The Swoole developers probably don't know about it, and unless you report it, chances are it won't be fixed. You can read How to report a bug doc before submitting any bug reports:

    https://github.com/swoole/swoole-src/blob/master/.github/ISSUE.md Please do not send bug reports in the mailing list or personal letters. The issue page is also suitable to submit feature requests.

OS: Linux 6.5.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 4 14:39:20 UTC 2 x86_64 GCC_VERSION: 11.4.0 OPENSSL_VERSION: OpenSSL 3.0.2 15 Mar 2022 PHP_VERSION : 8.1.26

  1. What did you expect to see?

  2. What did you see instead?

  3. What version of Swoole are you using (show your php --ri swoole)? swoole

Swoole => enabled Author => Swoole Team team@swoole.com Version => 5.1.1 Built => Dec 1 2023 13:40:59 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 3.0.2 15 Mar 2022 dtls => enabled http2 => enabled json => enabled curl-native => enabled pcre => enabled mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => enabled async_redis => enabled

Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_fiber_mock => Off => Off swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ? uname -a Linux feng-dev 6.5.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 4 14:39:20 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

php8.1 -v PHP 8.1.28 (cli) (built: Apr 22 2024 09:45:11) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.28, Copyright (c) Zend Technologies with Zend OPcache v8.1.28, Copyright (c), by Zend Technologies with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans

gcc -v

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

框架环境:hyperf 3.1

NathanFreeman commented 3 weeks ago

https://wiki.swoole.com/zh-cn/#/other/tools?id=gdb https://wiki.swoole.com/zh-cn/#/other/issue?id=关于段错误核心转储 看看能不能通过gdb贴一下程序出现问题的栈堆

fpysky commented 3 weeks ago

GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help". Type "apropos word" to search for commands related to "word". Attaching to process 35353 [New LWP 35357] [New LWP 35358] [New LWP 35359] [New LWP 35360] [New LWP 35361] [New LWP 35362] [New LWP 35363] [New LWP 35364] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 0x0000701e81725e2e in epoll_wait (epfd=34, events=0x5a8a6efd1d70, maxevents=4096, timeout=1000) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30 30 ../sysdeps/unix/sysv/linux/epoll_wait.c: 没有那个文件或目录.

fpysky commented 3 weeks ago

GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help". Type "apropos word" to search for commands related to "word". Attaching to process 35353 [New LWP 35357] [New LWP 35358] [New LWP 35359] [New LWP 35360] [New LWP 35361] [New LWP 35362] [New LWP 35363] [New LWP 35364] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 0x0000701e81725e2e in epoll_wait (epfd=34, events=0x5a8a6efd1d70, maxevents=4096, timeout=1000) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30 30 ../sysdeps/unix/sysv/linux/epoll_wait.c: 没有那个文件或目录.

这是 gdb -p master进程ID

NathanFreeman commented 3 weeks ago

https://wiki.swoole.com/zh-cn/#/other/issue?id=关于段错误核心转储 看看能不能生成core文件,或者把SWOOLE_PROCESS模式换成SWOOLE_BASE模式,看看这问题还会不会发生

fpysky commented 3 weeks ago

https://wiki.swoole.com/zh-cn/#/other/issue?id=关于段错误核心转储 看看能不能生成core文件,或者把SWOOLE_PROCESS模式换成SWOOLE_BASE模式,看看这问题还会不会发生

改成SWOOLE_BASE错误依旧,生成core文件要重新编译swoole扩展,不过我是通过apt install php8.1-swoole 这种方式安装的,重新编译相同版本的安装就不知道能不能复现了,我可以试试

NathanFreeman commented 3 weeks ago

看一下php -m输出一下扩展列表

fpysky commented 3 weeks ago

[PHP Modules] calendar Core ctype curl date dom exif FFI fileinfo filter ftp gd gettext hash http iconv igbinary json libxml mbstring mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix raphf readline redis Reflection session shmop SimpleXML sockets sodium SPL standard swoole sysvmsg sysvsem sysvshm tokenizer xdebug xml xmlreader xmlwriter xsl yaml Zend OPcache zip zlib

[Zend Modules] Xdebug Zend OPcache

NathanFreeman commented 3 weeks ago

屏蔽掉Xdebug试试看

fpysky commented 3 weeks ago

卸载xdebug就正常了,不是说8.1后xdebug可以用了吗

NathanFreeman commented 3 weeks ago

php --ri xdebug看看xdebug详细信息,swoole5.1修改过一次跟xdebug有关的bug,可能是新的问题,我要看看

fpysky commented 3 weeks ago

xdebug


\ \ / / | | | |
\ V / __| | | | _ _

< / ` |/ \ ' | | | |/ ` | / . \ (_| | / |) | || | (| | // __,|_|./ \,|_, | / | |/

Version => 3.3.2 Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support

         Enabled Features (through 'xdebug.mode' setting)             

Feature => Enabled/Disabled Development Helpers => ✔ enabled Coverage => ✘ disabled GC Stats => ✘ disabled Profiler => ✘ disabled Step Debugger => ✘ disabled Tracing => ✘ disabled

                        Optional Features                            

Compressed File Support => yes (gzip) Clock Source => clock_gettime 'xdebug://gateway' pseudo-host support => yes 'xdebug://nameserver' pseudo-host support => yes Systemd Private Temp Directory => not enabled

Directive => Local Value => Master Value xdebug.mode => develop => develop xdebug.start_with_request => default => default xdebug.start_upon_error => default => default xdebug.output_dir => /tmp => /tmp xdebug.use_compression => 1 => 1 xdebug.trigger_value => no value => no value xdebug.file_link_format => no value => no value xdebug.filename_format => no value => no value xdebug.control_socket => time: 25ms => time: 25ms xdebug.log => no value => no value xdebug.log_level => 7 => 7 xdebug.var_display_max_children => 128 => 128 xdebug.var_display_max_data => 512 => 512 xdebug.var_display_max_depth => 3 => 3 xdebug.max_nesting_level => 512 => 512 xdebug.cli_color => 0 => 0 xdebug.force_display_errors => Off => Off xdebug.force_error_reporting => 0 => 0 xdebug.halt_level => 0 => 0 xdebug.max_stack_frames => -1 => -1 xdebug.show_error_trace => Off => Off xdebug.show_exception_trace => Off => Off xdebug.show_local_vars => Off => Off xdebug.dump.COOKIE => no value => no value xdebug.dump.ENV => no value => no value xdebug.dump.FILES => no value => no value xdebug.dump.GET => no value => no value xdebug.dump.POST => no value => no value xdebug.dump.REQUEST => no value => no value xdebug.dump.SERVER => no value => no value xdebug.dump.SESSION => no value => no value xdebug.dump_globals => On => On xdebug.dump_once => On => On xdebug.dump_undefined => Off => Off xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p xdebug.profiler_append => Off => Off xdebug.cloud_id => no value => no value xdebug.client_host => localhost => localhost xdebug.client_port => 9003 => 9003 xdebug.discover_client_host => Off => Off xdebug.client_discovery_header => HTTP_X_FORWARDED_FOR,REMOTE_ADDR => HTTP_X_FORWARDED_FOR,REMOTE_ADDR xdebug.idekey => no value => no value xdebug.connect_timeout_ms => 200 => 200 xdebug.scream => Off => Off xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p xdebug.trace_output_name => trace.%c => trace.%c xdebug.trace_format => 0 => 0 xdebug.trace_options => 0 => 0 xdebug.collect_assignments => Off => Off xdebug.collect_params => On => On xdebug.collect_return => Off => Off xdebug.auto_trace => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.collect_includes => (setting removed in Xdebug 3) => (setting removed in Xdebug 3) xdebug.collect_vars => (setting removed in Xdebug 3) => (setting removed in Xdebug 3) xdebug.coverage_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.default_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.gc_stats_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.gc_stats_output_dir => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.overload_var_dump => (setting removed in Xdebug 3) => (setting removed in Xdebug 3) xdebug.profiler_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.profiler_enable_trigger => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.profiler_enable_trigger_value => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.profiler_output_dir => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_autostart => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_connect_back => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_host => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_log => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_log_level => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_mode => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_port => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.remote_timeout => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.show_mem_delta => (setting removed in Xdebug 3) => (setting removed in Xdebug 3) xdebug.trace_output_dir => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.trace_enable_trigger => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3) xdebug.trace_enable_trigger_value => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)

NathanFreeman commented 3 weeks ago

我没法复现这个问题,看看能不能提供一份最小化代码以供复现

fpysky commented 3 weeks ago

hyperf-demo.zip

dhobi commented 2 weeks ago

Sorry for hijacking this thread. I just wanted to share my observation that crashes stop happening for me when I disable the xdebug (3.3.2) extension.

php8.3-swoole5.1.1

When does the crash happen: The crash, if xdebug is enabled, happens in a task worker which is listening for events on a redis queue (subscribe). Whenever the redis connection is forcibly closed by the redis server (due to inactivity), the task worker crashes and is automatically restarted by swoole. If xdebug is not enabled, my code is able to handle the close event and create a new redis client & subscribe like intended.