swoole / swoole-src

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

Using stevebauman/purify with swoole and pre/code tags enabled crashes worker processes. #5083

Open kolaente opened 1 year ago

kolaente commented 1 year ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.

I've been using the purify library to sanitize html content. Once I added pre and code tags to the list of allowed html elements, the swoole process crashed. I'll try to pin it to where the problem was caused but didn't have any luck so far.

  1. What did you expect to see?

Sanitized html output.

  1. What did you see instead?

Swoole worker process crash, error message in the logs:

[2023-06-28 16:46:55 #30.0] WARNING Server::check_worker_exit_status(): worker(pid=146, id=10) abnormal exit, status=0, signal=11
  1. What version of Swoole are you using (show your php --ri swoole)?
root@2114b38e8450:/var/www# php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 5.0.3
Built => Jun 26 2023 00:31:00
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
http2 => enabled
json => enabled
pcre => enabled
zlib => 1.2.11
brotli => E16777225/D16777225
mutex_timedlock => enabled
pthread_barrier => enabled
futex => 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

I'm using swoole with Laravel Octane.

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
NathanFreeman commented 1 year ago

I will test it later.

NathanFreeman commented 1 year ago

@kolaente Hi. I can not reproduce it. Could you please use valgrind to track your program? Have you used the xdebug extension?

kolaente commented 1 year ago

Could you please use valgrind to track your program?

How do I do that?

Have you used the xdebug extension?

I didn't use it.

NathanFreeman commented 1 year ago

Sorry, I hase made a mistake, use gdb to track your program.

ps aux | grep swoole

图片

gdb attach 651337

And now executing your code until trigger the error.