walkor / webman

Probably the fastest PHP web framework in the world.
https://webman.workerman.net/
MIT License
2.21k stars 216 forks source link

Webman fail with php8.1 #249

Closed joanhey closed 2 years ago

joanhey commented 2 years ago

Hi, as the ppa:ondrej/php include now php8.1-rc5, I'm testing the frameworks for the benchmark.

Workerman is working OK, but Webman is failing. The worst thing, it's that don't show any error in the first run, only: Verifying test query for webman caused an exception: ('Connection aborted.', BadStatusLine('No status line received - the server has closed the connection',)) that come from the test.

In the second run, give me the same error and webman: worker[webman:43] exit with status 139. That look like a segmentation fault.

But will be good if webman try to return a better error. PHP8.1 final will be released 25th from this month.

walkor commented 2 years ago

Hi joanhey, thank you for your post.

webman: worker[webman:43] exit with status 139. That look like a segmentation fault.

Yes, you are right, it is a segmentation fault. That means php8.1-rc5 has a bug.

But will be good if webman try to return a better error.

When a segment error occurs, the process is forced to exit and all connections are destroyed. PHP code can't catch this error or control it, so there's basically no way to give users better error info.

Later I will try to find out which code triggered this crash.

joanhey commented 2 years ago

Plain Workerman and kumbiaphp with workerman for now work OK with php8.1. Trying with more frameworks now.

Curiously kumbia with nginx fail for preg_match() but not with workerman that is also using preg_match() exactly egual.

walkor commented 2 years ago

preg_match(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in file /root/FrameworkBenchmarks/frameworks/PHP/webman/vendor/workerman/workerman/Worker.php on line 1056

preg_match_all(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in file /root/FrameworkBenchmarks/frameworks/PHP/webman/vendor/workerman/workerman/Worker.php on line 794

PHP Warning: preg_split(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in /root/FrameworkBenchmarks/frameworks/PHP/webman/vendor/nikic/fast-route/src/RouteParser/Std.php on line 31

Warning: preg_replace(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in Standard input code on line 1252 ( Similar error with composer too)

There are some warnings for preg_* with php8.1 - RC5. Webman required nikic/fast-route which broken with preg_split too . I think php8.1-rc5 changed something with regular expression . I decided to wait for the official release of php8.1 and then decide whether to fix preg_related issues.

joanhey commented 2 years ago

Yes, exist a problem with preg_*, but other frameworks show the error, but not Webman. Perhaps to see the errors you are usingstream_select()`, but now it's the moment to try to show the errors when exist a php problem using another ext event loop.

walkor commented 2 years ago

Ok, I will fix it later.

walkor commented 2 years ago

Curiously kumbia with nginx fail for preg_match() but not with workerman that is also using pregmatch() exactly egual. Yes, exist a problem with `preg*`, but other frameworks show the error, but not Webman.

I find out the key, when php8.1-dev installed the preg_* has no errors that why webman or workerman not show preg_* errors.

joanhey commented 2 years ago

Kumbiaphp-workerman pass the tests, but with errors. ~As Kumbia show more info, perhaps will be useful to help in finding the problem:~

kumbiaphp-workerman: Entering debug mode. Server http://localhost:8080 has started. CTRL-c to stop.
kumbiaphp-workerman: From outside vagrant: http://localhost:28080
kumbiaphp-workerman: Error: Class "Kumbia\ActiveRecord\LiteRecord" not found in /kumbiaphp/bench/app/models/world.php:3
kumbiaphp-workerman: Stack trace:
kumbiaphp-workerman: #0 /kumbiaphp/vendor/Kumbia/core/kumbia/autoload.php(49): include()
kumbiaphp-workerman: #1 /kumbiaphp/bench/app/controllers/db_controller.php(13): kumbia_autoload('World')
kumbiaphp-workerman: #2 /kumbiaphp/vendor/Kumbia/core/kumbia/router.php(158): DbController->index()
kumbiaphp-workerman: #3 /kumbiaphp/vendor/Kumbia/core/kumbia/static_router.php(61): Router::dispatch(Object(DbController))
kumbiaphp-workerman: #4 /kumbiaphp/vendor/Kumbia/core/kumbia/router.php(122): StaticRouter::dispatch(Object(DbController))
kumbiaphp-workerman: #5 /kumbiaphp/vendor/Kumbia/core/kumbia/static_router.php(43): Router::execute('/db')
kumbiaphp-workerman: #6 /kumbiaphp/vendor/Kumbia/core/kumbia/workerboot.php(63): StaticRouter::execute('/db')
kumbiaphp-workerman: #7 /kumbiaphp/server.php(17): kumbiaSend()
kumbiaphp-workerman: #8 /kumbiaphp/vendor/workerman/workerman/Connection/TcpConnection.php(656): {closure}(Object(Workerman\Connection\TcpConnection), Array)
kumbiaphp-workerman: #9 [internal function]: Workerman\Connection\TcpConnection->baseRead(Resource id #33, 2, Resource id #33)
kumbiaphp-workerman: #10 /kumbiaphp/vendor/workerman/workerman/Events/Event.php(195): EventBase->loop()
kumbiaphp-workerman: #11 /kumbiaphp/vendor/workerman/workerman/Worker.php(2408): Workerman\Events\Event->loop()
kumbiaphp-workerman: #12 /kumbiaphp/vendor/workerman/workerman/Worker.php(1541): Workerman\Worker->run()
kumbiaphp-workerman: #13 /kumbiaphp/vendor/workerman/workerman/Worker.php(1371): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker))
kumbiaphp-workerman: #14 /kumbiaphp/vendor/workerman/workerman/Worker.php(1345): Workerman\Worker::forkWorkersForLinux()
kumbiaphp-workerman: #15 /kumbiaphp/vendor/workerman/workerman/Worker.php(546): Workerman\Worker::forkWorkers()
kumbiaphp-workerman: #16 /kumbiaphp/server.php(20): Workerman\Worker::runAll()
kumbiaphp-workerman: #17 {main}

SORRY: This error is normal (bad url). but still exist the problem with the memory.

Also I update the ini with memory_limit = 1024M from the before 512M, but still eat all the memory.

I don't know from where is the problem for now: php, libevent or workerman. Perhaps together we can find the problem.

https://github.com/php/php-src/blob/php-8.1.0RC6/UPGRADING

joanhey commented 2 years ago

~As the errors all point to the include(), perhaps is a problem with the new Inheritance Cache in CLI mode. https://externals.io/message/113091~

joanhey commented 2 years ago

Tried disabling JIT and OPCache, but the errors persist.

Checking the libevent extension issues, I don't find anything relevant to this problem. Well perhaps issue 69. https://bitbucket.org/osmanov/pecl-event/issues

walkor commented 2 years ago

It's strange, I just ran it, but I didn't see that errors.

image

image

joanhey commented 2 years ago

Kumbia only fail with kumbiaphp-workerma-mysql (using the ORM).

And only in the update test in the tfb --mode verify. Using tfb --mode debug work perfect without errors.

And show the same error than webman: in /run/ .log worker[none:13] exit with status 139 in the output: Verifying test update for kumbiaphp-workerman-mysql caused an exception: ('Connection aborted.', BadStatusLine('No status line received - the server has closed the connection',))

joanhey commented 2 years ago

I will check the update test code, as the problem is the same than with webman.

joanhey commented 2 years ago

Comet that use workerman have another error: Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /comet/vendor/workerman/workerman/Protocols/Http/Request.php on line 166

That error is normal in php8.1
https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation

But also have some 139:

comet: Workerman[/comet/app.php] start in DEBUG mode
comet: worker[Comet v0.7.2:17] exit with status 139
comet: worker[Comet v0.7.2:14] exit with status 139
comet: worker[Comet v0.7.2:15] exit with status 139
comet: worker[Comet v0.7.2:18] exit with status 139
comet: worker[Comet v0.7.2:16] exit with status 139
comet: worker[Comet v0.7.2:13] exit with status 139
comet: worker[Comet v0.7.2:19] exit with status 139
comet: Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /comet/vendor/workerman/workerman/Protocols/Http/Request.php on line 166
joanhey commented 2 years ago

Run log of webman:

webman: Workerman[/webman/start.php] start in DEBUG mode
webman: ----------------------------------------- WORKERMAN -----------------------------------------
webman: Workerman version:4.0.22          PHP version:8.1.0RC5
webman: ------------------------------------------ WORKERS ------------------------------------------
webman: proto   user            worker          listen                 processes    status           
webman: tcp     root            webman          http://0.0.0.0:8080    8             [OK]            
webman: ---------------------------------------------------------------------------------------------
webman: Press Ctrl+C to stop. Start success.
webman: worker[webman:18] exit with status 135
webman: worker[webman:15] exit with status 135
webman: worker[webman:12] exit with status 135
webman: worker[webman:14] exit with status 135
webman: worker[webman:19] exit with status 135
webman: worker[webman:11] exit with status 135
webman: worker[webman:17] exit with status 135
webman: worker[webman:49] exit with status 139
webman: worker[webman:45] exit with status 139
webman: worker[webman:41] exit with status 139
webman: worker[webman:35] exit with status 139
webman: worker[webman:44] exit with status 139
webman: worker[webman:51] exit with status 139

Run log of kumbiaphp-workerman-mysql:

kumbiaphp-workerman-mysql: Workerman[server.php] start in DEBUG mode
kumbiaphp-workerman-mysql: ----------------------------------------- WORKERMAN -----------------------------------------
kumbiaphp-workerman-mysql: Workerman version:3.5.31          PHP version:8.1.0RC5
kumbiaphp-workerman-mysql: ------------------------------------------ WORKERS ------------------------------------------
kumbiaphp-workerman-mysql: proto   user            worker          listen                 processes    status           
kumbiaphp-workerman-mysql: tcp     root            none            http://0.0.0.0:8080    8             [OK]            
kumbiaphp-workerman-mysql: ---------------------------------------------------------------------------------------------
kumbiaphp-workerman-mysql: Press Ctrl+C to stop. Start success.
kumbiaphp-workerman-mysql: worker[none:13] exit with status 139
walkor commented 2 years ago

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /comet/vendor/workerman/workerman/Protocols/Http/Request.php on line 166

This has fixed in workerman master.

walkor commented 2 years ago
webman: worker[webman:44] exit with status 139

That seems opcache's bug in php8.1.0RC6, when I disabled opcache by opcache.enable_cli=0 the error disappeared for webman and kumbiaphp-workerman-mysql.

joanhey commented 2 years ago

Without opcache is working. With opcache and without jit fail.

And in the actual run kumbia-workeman, that pass the verify, had failed in all the tests: [kumbiaphp-workerman] failed: json db query fortune update plaintext In local, run the benchmark without any error.

In about 2 days we could check which fw passed, and watch the logs. We need to isolate this bug.

PD: php 8.1 is really fast. Cakephp and laravel with fastcgi are about 100% faster in all tests.

joanhey commented 2 years ago

Mixphp-workerman passed the run with mysql (orm) and postgresql raw. The performance gain is about 2-3%.

joanhey commented 2 years ago

Ubiquity-workerman and workerman plain both worked OK.

Kumbiaphp-workerman failed with the same status 139: https://tfb-status.techempower.com/unzip/results.2021-11-18-19-10-12-391.zip/results/20211114055625/kumbiaphp-workerman/run/kumbiaphp-workerman.log

But in local worked without any problem. Update: in the last run worked without problems.

joanhey commented 2 years ago

Tested with event 3.0.7RC1 (beta) and the same problem.

joanhey commented 2 years ago

Tested without event extension and the same problem. So the problem will be in the opcache in php 8.1.

Well, Webman pass the plaintext and fail with the others.

joanhey commented 2 years ago

With only 1 process it's working OK.

haidarvm commented 2 years ago

Ok its works with PHP 8.1, but got error on my custom route on url http://server.com/2021/11/24/title ErrorException: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /home/haidar/public_html/server/vendor/workerman/workerman/Protocols/Http/Request.php:446 Stack trace:

0 [internal function]: {closure}()

1 /home/haidar/public_html/server/vendor/workerman/workerman/Protocols/Http/Request.php(446): parse_str()

2 /home/haidar/public_html/server/vendor/workerman/workerman/Protocols/Http/Request.php(111): Workerman\Protocols\Http\Request->parseGet()

3 /home/haidar/public_html/server/app/controller/Read.php(29): Workerman\Protocols\Http\Request->get()

4 /home/haidar/public_html/server/app/controller/Read.php(77): app\controller\Read->single()

5 /home/haidar/public_html/server/vendor/workerman/webman-framework/src/App.php(253): app\controller\Read->date_slug()

6 /home/haidar/public_html/server/vendor/workerman/webman-framework/src/App.php(315): Webman\App::Webman{closure}()

7 /home/haidar/public_html/server/vendor/workerman/webman-framework/src/App.php(154): Webman\App::findRoute()

8 /home/haidar/public_html/server/vendor/workerman/workerman/Connection/TcpConnection.php(638): Webman\App->onMessage()

9 /home/haidar/public_html/server/vendor/workerman/workerman/Events/Select.php(294): Workerman\Connection\TcpConnection->baseRead()

10 /home/haidar/public_html/server/vendor/workerman/workerman/Worker.php(2418): Workerman\Events\Select->loop()

11 /home/haidar/public_html/server/vendor/workerman/workerman/Worker.php(1542): Workerman\Worker->run()

12 /home/haidar/public_html/server/vendor/workerman/workerman/Worker.php(1373): Workerman\Worker::forkOneWorkerForLinux()

13 /home/haidar/public_html/server/vendor/workerman/workerman/Worker.php(1347): Workerman\Worker::forkWorkersForLinux()

14 /home/haidar/public_html/server/vendor/workerman/workerman/Worker.php(542): Workerman\Worker::forkWorkers()

15 /home/haidar/public_html/server/start.php(129): Workerman\Worker::runAll()

16 {main}

haidarvm commented 2 years ago

and session error

PHP Fatal error: During inheritance of SessionHandlerInterface: Uncaught ErrorException: Return type of W orkerman\Protocols\Http\Session\FileSessionHandler::open($save_path, $name) should either be compatible wi th SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attrib ute should be used to temporarily suppress the notice in /home/haidar/public_html//vendor/w orkerman/workerman/Protocols/Http/Session/FileSessionHandler.php:60

walkor commented 2 years ago

@haidarvm Please upgrade workerman/workerman to v4.0.23 or greater. upgrade workerman/webman-framework to v1.0.21 or greater. upgrade workerman/webman tp v1.1.3 or grater.

joanhey commented 2 years ago

Fixed.

~Any chance to fix workerman v3.5 for php 8.1 ?~