pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.26k stars 1.53k forks source link

Enabling Xdebug on PM5 with PHP 8.2 causes ConsoleReaderChildProcessDaemon to be crashed #5561

Open alvin0319 opened 1 year ago

alvin0319 commented 1 year ago

Link to crashdump: https://pastebin.com/HmAFJ0QF

Additional comments (optional)

My php.ini setting:

;Custom PocketMine-MP php.ini file
memory_limit=1024M
display_errors=1
display_startup_errors=1
error_reporting=-1
zend.assertions=-1
extension_dir=ext
extension=php_pthreads.dll
extension=php_openssl.dll
extension=php_chunkutils2.dll
extension=php_igbinary.dll
extension=php_leveldb.dll
extension=php_crypto.dll
extension=php_libdeflate.dll
igbinary.compact_strings=0
zend_extension=php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.save_comments=1
opcache.validate_timestamps=1
opcache.revalidate_freq=0
opcache.file_update_protection=0
opcache.optimization_level=0x7FFEBFFF
opcache.cache_id=PHP_BINARY ;prevent sharing SHM between different binaries - they won't work because of ASLR
;Optional extensions, supplied for PM3 use
;Optional extensions, supplied for plugin use
extension=php_fileinfo.dll
extension=php_gd.dll
extension=php_mysqli.dll
extension=php_sqlite3.dll
;Optional extensions, supplied for debugging
extension=php_recursionguard.dll
recursionguard.enabled=0 ;disabled due to minor performance impact, only enable this if you need it for debugging

; ---- ! WARNING ! ----
; JIT can provide big performance improvements, but as of PHP 8.0.8 it is still unstable. For this reason, it is disabled by default.
; Enable it at your own risk. See https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit for possible options.
opcache.jit=off
opcache.jit_buffer_size=128M

;WARNING: When loaded, xdebug 3.2.0 will cause segfaults whenever an uncaught error is thrown, even if xdebug.mode=off. Load it at your own risk.
zend_extension=php_xdebug.dll
;https://xdebug.org/docs/all_settings#mode
xdebug.mode=debug
xdebug.start_with_request=yes
;The following overrides allow profiler, gc stats and traces to work correctly in ZTS
xdebug.profiler_output_name=cachegrind.%s.%p.%r
xdebug.gc_stats_output_name=gcstats.%s.%p.%r
xdebug.trace_output_name=trace.%s.%p.%r

No breakpoints (or checkpoints) have been made at this point, server just crashed without any plugins.

dktapps commented 1 year ago

That's odd. I've never seen this, and I'm using 8.2 with xdebug locally.

alvin0319 commented 1 year ago

I wonder if this is a Windows-specific error, I've tried enabling Xdebug on Ubuntu 22.04 (on VM) and it worked fine. (and debugger connection was successful too)

dktapps commented 1 year ago

To be honest, I think it's more likely this has something to do with xdebug/xdebug#878.

dktapps commented 1 year ago

Is this issue still present with latest PHP binaries?

alvin0319 commented 1 year ago

Wed_Sep_6-09.34.51-UTC_2023.log The issue still persists.

Apart from the crashing, my plugins that make external connections (127.0.0.1, or other external IPs) aren't established successfully. (My plugins block a main thread to wait for a successful connection. This makes the main thread blocked)

My investigation shows that every external (or, internal) connection (or socket?) PHP made doesn't establish whenever used with xdebug. This has been tested with:

alvin0319 commented 6 months ago

Bump, The issue still happens on my PC. By the way, not sure if it's related, compiling PHP binary on my PC fails on xdebug compilation.

NMAKE : fatal error U1077: '"cl.exe" /D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_XDEBUG /D XDEBUG_EXPORTS=1 /I ext\xdebug /I ext\xdebug/src /nologo /I . /I main /I Zend /I TSRM /I ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /FD /wd4996 /Zc:inline /Gw /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP /Zi /LD /MD /Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "C:\pocketmine-php-8.3.0-release\deps\include" /D FD_SETSIZE=256 /FoC:\pocketmine-php-8.3.0-release\php-src\x64\Release_TS\ext\xdebug\src\lib\ /FpC:\pocketmine-php-8.3.0-release\php-src\x64\Release_TS\ext\xdebug\src\lib\ /FRC:\pocketmine-php-8.3.0-release\php-src\x64\Release_TS\ext\xdebug\src\lib\ /FdC:\pocketmine-php-8.3.0-release\php-src\x64\Release_TS\ext\xdebug\src\lib\ /c ext\xdebug\src\lib\cmd_parser.c ext\xdebug\src\lib\compat.c ext\xdebug\src\lib\crc32.c ext\xdebug\src\lib\file.c ext\xdebug\src\lib\hash.c ext\xdebug\src\lib\headers.c ext\xdebug\src\lib\lib.c ext\xdebug\src\lib\llist.c ext\xdebug\src\lib\log.c ext\xdebug\src\lib\set.c ext\xdebug\src\lib\str.c ext\xdebug\src\lib\timing.c ext\xdebug\src\lib\usefulstuff.c ext\xdebug\src\lib\var.c ext\xdebug\src\lib\var_export_html.c ext\xdebug\src\lib\var_export_line.c ext\xdebug\src\lib\var_export_text.c ext\xdebug\src\lib\var_export_xml.c ext\xdebug\src\lib\xml.c' : '0x2'   ȯ  ڵ  Դϴ .

Not sure why error message appears like that, and not sure how to fix it. (my editor is reading it as utf-8)

Full compile.log here: compile.log