swoole / yasd

Yet Another Swoole Debugger
https://huanghantao.github.io/yasd-wiki/
Apache License 2.0
357 stars 35 forks source link

调试时遇到错误`double free or corruption (!prev)` #106

Closed NHZEX closed 1 year ago

NHZEX commented 3 years ago

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provides a simple script and debug step to reproduce the problem.

debug imi-project

  1. What did you expect to see?

正常调试

  1. What did you see instead?
double free or corruption (!prev)
[2021-03-25 03:20:12 $633238.0] WARNING check_worker_exit_status: worker#3[pid=633246] abnormal exit, status=0, signal=6
  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
PHP 7.4.16 (cli) (built: Mar  5 2021 07:54:38) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.6.4
Built => Mar 20 2021 02:13:40
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1j  16 Feb 2021
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
zlib => 1.2.11
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_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
Yasd => enabled
Author => codinghuang <codinghuang@qq.com>
Version => 0.3.7
Built => Mar 19 2021 02:28:16

Directive => Local Value => Master Value
yasd.breakpoints_file => no value => no value
yasd.debug_mode => remote => remote
yasd.remote_host => 192.168.10.1 => 192.168.10.1
yasd.remote_port => 9000 => 9000
yasd.depth => 1 => 1
yasd.log_level => -1 => -1
yasd.max_executed_opline_num => 0 => 0
yasd.init_file => no value => no value
xdebug.coverage_enable => 1 => 1
xdebug.profiler_enable => 1 => 1
xdebug.remote_autostart => 1 => 1
xdebug.remote_connect_back => 0 => 0
xdebug.remote_mode => req => req

编译的是最新分支:7f00cb8ae884b1ed3a02d019eab24ea5c36449c5

最初运行时还出现了个:core dump

Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) l
150     in ../sysdeps/posix/libc_fatal.c
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f1834cc6859 in __GI_abort () at abort.c:79
#2  0x00007f1834d313ee in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7f1834e5b285 "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#3  0x00007f1834d3947c in malloc_printerr (str=str@entry=0x7f1834e5d600 "free(): invalid next size (fast)") at malloc.c:5347
#4  0x00007f1834d3ad2c in _int_free (av=0x7f1834e8cb80 <main_arena>, p=0x55b52a609f50, have_lock=0) at malloc.c:4249
#5  0x00007f1834f11e0e in pcre2_code_free_8 () from /lib/x86_64-linux-gnu/libpcre2-8.so.0
#6  0x000055b5287fc4a6 in ?? ()
#7  0x000055b5289619f2 in zend_hash_destroy ()
#8  0x000055b5287fc388 in ?? ()
#9  0x000055b528957054 in zend_deactivate_modules ()
#10 0x000055b5288f0385 in php_request_shutdown ()
#11 0x000055b5289dcc44 in ?? ()
#12 0x000055b5287b7138 in ?? ()
#13 0x00007f1834cc80b3 in __libc_start_main (main=0x55b5287b6d30, argc=9, argv=0x7ffc976d95a8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffc976d9598) at ../csu/libc-start.c:308
#14 0x000055b5287b72de in _start ()
huanghantao commented 3 years ago

看报错感觉是pcre扩展出现了内存问题,你关闭pcre扩展试试?

NHZEX commented 3 years ago

看报错感觉是pcre扩展出现了内存问题,你关闭pcre扩展试试?

https://www.php.net/manual/zh/pcre.installation.php

PCRE 是 PHP 核心扩展,所以总是启用的

这个方案不太可行吧,而且项目依赖正则,关了就运行不起来了。

huanghantao commented 3 years ago

能否提供一个github仓库,我可以下载项目,然后调试复现出你这个问题?

NHZEX commented 3 years ago

能否提供一个github仓库,我可以下载项目,然后调试复现出你这个问题?

我试试看

NHZEX commented 3 years ago

能否提供一个github仓库,我可以下载项目,然后调试复现出你这个问题?

在容器里错误变成里corrupted size vs. prev_size

https://github.com/NHZEX/yasd-tests

sudo docker build -t imi_test:yasd .

sudo docker run -it --rm \
 -p 9988:9988 \
 -e IMI_DEBUG=true \
 -e MAIN_DB_HOST=192.168.1.166 \
 -e MAIN_DB_PORT=3306 \
 -e MAIN_DB_DATABASE=db \
 -e MAIN_DB_USERNAME=db \
 -e MAIN_DB_PASSWORD=password \
 -e DEBUG_HOST=192.168.138.124 \
 imi_test:yasd

请求多几次,不是每次都出现的。 Get: http://192.168.138.122:9988/api

之前还有个项目是corrupted size vs. prev_sizedouble free or corruption (!prev)交替发生

[MASK]/Listener/DbExecuteListener.php:27
2021-03-25 08:40:32 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00237] [MASK]/Listener/DbExecuteListener.php:27
corrupted size vs. prev_size
[2021-03-25 08:40:33 $17.0]     WARNING check_worker_exit_status: worker#2[pid=24] abnormal exit, status=0, signal=6
2021-03-25 08:45:02 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.01150] [MASK]/Listener/DbExecuteListener.php:27
2021-03-25 08:45:02 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00238] [MASK]/Listener/DbExecuteListener.php:27
2021-03-25 08:45:03 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00219] [MASK]/Listener/DbExecuteListener.php:27
corrupted size vs. prev_size
[2021-03-25 08:45:03 $17.0]     WARNING check_worker_exit_status: worker#1[pid=48] abnormal exit, status=0, signal=6
2021-03-25 08:45:05 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00280] [MASK]/Listener/DbExecuteListener.php:27
2021-03-25 08:45:06 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00272] [MASK]/Listener/DbExecuteListener.php:27
2021-03-25 08:45:06 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00270] [MASK]/Listener/DbExecuteListener.php:27
corrupted size vs. prev_size
[2021-03-25 08:45:06 $17.0]     WARNING check_worker_exit_status: worker#1[pid=62] abnormal exit, status=0, signal=6
2021-03-25 08:45:06 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00271] [MASK]/Listener/DbExecuteListener.php:27
2021-03-25 08:45:07 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00286] [MASK]/Listener/DbExecuteListener.php:27
corrupted size vs. prev_size
[2021-03-25 08:45:07 $17.0]     WARNING check_worker_exit_status: worker#2[pid=53] abnormal exit, status=0, signal=6
2021-03-25 08:45:07 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.01248] [MASK]/Listener/DbExecuteListener.php:27
2021-03-25 08:45:07 [debug] [SQL Execute] SHOW STATUS (vars:[]) [0.00276] [MASK]/Listener/DbExecuteListener.php:27
corrupted size vs. prev_size
[2021-03-25 08:45:08 $17.0]     WARNING check_worker_exit_status: worker#1[pid=67] abnormal exit, status=0, signal=6
lobtao commented 2 years ago

hyperf 2.2只要有sql查询,必然出现 [2022-01-19 16:05:30 $4178.0] WARNING Server::check_worker_exit_status(): worker(pid=6771, id=0) abnormal exit, status=0, signal=11 A bug occurred in Swoole-v4.8.6, 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 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 GCC_VERSION: 7.5.0 OPENSSL_VERSION: OpenSSL 1.1.1 11 Sep 2018 PHP_VERSION : 7.4.27

wsl1,Ubuntu 18.04,hyperf 2.2,swoole 4.8.6,yasd 0.3.9-alpha,PHP 7.4.27

huanghantao commented 1 year ago

可以考虑使用 swoole-src的 xdebug分支,https://github.com/swoole/swoole-src/tree/support-xdebug 可以直接使用xdebug进行调试,前提是PHP版本要大于等于8.1