openswoole / ext-openswoole

Programmatic server for PHP with async IO, coroutines and fibers
https://openswoole.com
Apache License 2.0
808 stars 51 forks source link

Opcache & protect_memory options = segfault #196

Closed mrVrAlex closed 2 years ago

mrVrAlex commented 2 years ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error. Just put options to PHP (opcache) ini file: opcache.protect_memory = 1 to swoole unit tests

  2. What did you expect to see?

Some exceptions to catch? Normal work?

  1. What did you see instead?

Segmentaion fault in worker process:

Program received signal SIGSEGV, Segmentation fault. operator() (response=0x7f12f9a62da0, key=0x7f12fcdb0b58 "Content-Type", l_key=12, value=, __closure=) at /tmp/swoole-src/ext-src/swoole_http_response.cc:350 warning: Source file is more recent than executable. 350 str_value.rtrim(); (gdb) bt

0 operator() (response=0x7f12f9a62da0, key=0x7f12fcdb0b58 "Content-Type", l_key=12, value=, __closure=) at /tmp/swoole-src/ext-src/swoole_http_response.cc:350

1 0x00007f12fa0b98c1 in http_build_header (ctx=ctx@entry=0x7f12f9a54ff0, response=response@entry=0x7f12f9a62da0, body_length=body_length@entry=1064866) at /tmp/swoole-src/ext-src/swoole_http_response.cc:375

2 0x00007f12fa0bba87 in swoole::http::Context::end (this=0x7f12f9a54ff0, zdata=, return_value=0x7ffe8cba8f00) at /tmp/swoole-src/ext-src/swoole_http_response.cc:718

3 0x0000555cbaa458a3 in execute_ex ()

4 0x0000555cba9caf17 in zend_call_function ()

5 0x00007f12fa08c0da in sw_zend_call_function_ex (retval=0x0, params=0x7b7a0279404b4906, param_count=2, fci_cache=0x7f12f88672c0, function_name=0x0) at /tmp/swoole-src/ext-src/php_swoole_private.h:953

6 zend::function::call (fci_cache=fci_cache@entry=0x7f12f88672c0, argc=argc@entry=2, argv=argv@entry=0x7ffe8cba90e0, retval=retval@entry=0x0, enable_coroutine=)

at /tmp/swoole-src/ext-src/php_swoole_cxx.cc:74

7 0x00007f12fa0bce57 in php_swoole_http_server_onReceive (serv=, req=) at /tmp/swoole-src/ext-src/swoole_http_server.cc:144

8 0x00007f12fa1a623d in std::function<int (swoole::Server, swoole::RecvData)>::operator()(swoole::Server, swoole::RecvData) const (args#1=, args#0=, this=0x7f12f99535c0)

at /usr/include/c++/10.3.1/bits/std_function.h:622

9 swoole::Worker_do_task (callback=..., task=0x7f12f7ca2010, worker=0x7f12f98af008, serv=0x7f12f9952fd0) at /tmp/swoole-src/src/server/worker.cc:213

10 swoole::Server::accept_task (this=0x7f12f9952fd0, task=0x7f12f7ca2010) at /tmp/swoole-src/src/server/worker.cc:235

11 0x00007f12fa1a7bb6 in swoole::Worker_onPipeReceive (reactor=, event=) at /tmp/swoole-src/src/server/worker.cc:705

12 0x00007f12fa18151e in swoole::ReactorEpoll::wait (this=0x7f12f9a62dd0, timeo=) at /tmp/swoole-src/src/reactor/epoll.cc:218

13 0x00007f12fa1a6e66 in swoole::Reactor::wait (timeout=0x0, this=0x7f12f9a14fb0) at /tmp/swoole-src/include/swoole_reactor.h:160

14 swoole::Server::start_event_worker (this=this@entry=0x7f12f9952fd0, worker=worker@entry=0x7f12f98af008) at /tmp/swoole-src/src/server/worker.cc:579

15 0x00007f12fa186bf5 in swoole::Server::spawn_event_worker (this=0x7f12f9952fd0, worker=0x7f12f98af008) at /tmp/swoole-src/src/server/manager.cc:628

16 0x00007f12fa187892 in swoole::Manager::start (this=0x7ffe8cba9680, _server=0x7f12f9952fd0) at /tmp/swoole-src/src/server/manager.cc:375

17 0x00007f12fa188aeb in swoole::Server::start_manager_process (this=0x7f12f9952fd0) at /tmp/swoole-src/src/server/manager.cc:189

18 0x00007f12fa199a8b in swoole::ProcessFactory::start (this=0x7f12f9a2a600) at /tmp/swoole-src/src/server/process.cc:123

19 0x00007f12fa192092 in swoole::Server::start (this=this@entry=0x7f12f9952fd0) at /tmp/swoole-src/src/server/master.cc:579

20 0x00007f12fa11104d in zim_swoole_server_start (execute_data=, return_value=0x7ffe8cba9870) at /tmp/swoole-src/ext-src/swoole_server.cc:2502

21 0x0000555cbaa458a3 in execute_ex ()

22 0x0000555cbaa45bff in zend_execute ()

23 0x0000555cba9d9430 in zend_execute_scripts ()

24 0x0000555cba975a23 in php_execute_script ()

  1. What version of OpenSwoole are you using (show your php --ri openswoole)?

4.11.0

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

Latest alpine docker image.

doubaokun commented 2 years ago

opcache.protect_memory=1 is only for internal debug usage: https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.protect-memory You have to turn this off.