Bug #81679 [Asn->Ver]: PHP 8 opcache crashing when using JIT on Windows 2019
| From: | cmb@php.net | Date: | Wed, 08 Dec 2021 19:13:59 +0000 |
| Subject: | Bug #81679 [Asn->Ver]: PHP 8 opcache crashing when using JIT on Windows 2019 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-238289@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81679&edit=1
ID: 81679
Updated by: cmb@php.net
Reported by: alex at ndros dot com
Summary: PHP 8 opcache crashing when using JIT on Windows
2019
-Status: Assigned
+Status: Verified
Type: Bug
Package: JIT
Operating System: Windows Server 2019
PHP Version: 8.0.13
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
It seems to me that the current tracing JIT implementation is
broken for any multiprocess Web SAPIs which *re*attach to OPcache
SHM (generally (F)CGI, but on Windows potentially any SAPI which
may run multiple PHP processes in parallel, unless they enforce
separate OPcache instances). The problem begins in
zend_jit_trace_startup[1] where SHM memory is allocated for
zend_jit_traces and zend_jit_exit_groups, but that would be
reallocated whenever a new process attaches to OPcache SHM. And
that appears to be the reason for the stack backtrace presented
above: where zend_jit_traces is not properly initialized to what
has been calculated previously, and as such causes a segfault.
That might be fixable without ABI break, but otherwise we should
make sure that tracing JIT is not available for such environments.
[1] <https://github.com/php/php-src/blob/php-8.0.13/ext/opcache/jit/zend_jit_trace.c#L51>
Previous Comments:
------------------------------------------------------------------------
[2021-12-08 13:57:54] cmb@php.net
Thanks for further input!
> From basic observation this seems to happen as soon as a second
> FastCGI php-cgi instance is started by IIS
Ah, right, something is wrong there. I need to investigate.
------------------------------------------------------------------------
[2021-12-08 12:16:49] ian dot fitzgerald at emapplications dot com
We also have this issue with our Wordpress website on Server 2019 after upgrading PHP7.3->8.0 and
enabling opcache+JIT. From basic observation this seems to happen as soon as a second FastCGI
php-cgi instance is started by IIS (instance limit set to 4).
I have generated this stack backtrace:
Faulting Thread entry point: php_cgi!mainCRTStartup
php_opcache!zend_jit_trace_exit+7d
[D:\a\php-ftw\php-ftw\php\vs16\x64\php-8.0.13\ext\opcache\jit\zend_jit_trace.c @ 7443 + 14]
0x00001000`080005cb
0x0000025d`00000003
0x0000009f`445fb630
0x0000025d`9d753e00
php8!zend_fetch_class+a0 [D:\a\php-ftw\php-ftw\php\vs16\x64\php-8.0.13\Zend\zend_execute_API.c @
1509 + 9]
Exception information:
xxxx.dmp the assembly instruction at php_opcache!zend_jit_trace_exit+7d in C:\Program
Files\php8\ext\php_opcache.dll from The PHP Group has caused an access violation exception
(0xC0000005) when trying to read from memory location 0x00000074 on thread 0
------------------------------------------------------------------------
[2021-12-01 11:03:22] cmb@php.net
I cannot reproduce this.
> This seem to happen to any PHP application.
Can you give a concrete example? Ideally, a minimal application
or even better a simple script.
A stack backtrace[1] might also be helpful.
[1] <https://bugs.php.net/bugs-generating-backtrace-win32.php>
------------------------------------------------------------------------
[2021-11-30 22:50:49] alex at ndros dot com
This seem to happen to any PHP application.
------------------------------------------------------------------------
[2021-11-30 22:50:04] alex at ndros dot com
Description:
------------
Hi!
We have discovered that as soon as we turn on jit with the following config;
opcache.jit_buffer_size=64M
opcache.jit=tracing
We (what it seems to be randomly) get crashes. Also, CPU get's compeltely bottlenecked at 100%
until we do IISRESET.
C:\Program Files\PHP\v8.0\php-cgi.exe - The FastCGI process exited unexpectedly
Module FastCgiModule
Handler php-8.0.13
Error Code 0xc0000005
-----
Faulting application name: php-cgi.exe, version: 8.0.13.0, time stamp: 0x619429f5
Faulting module name: php_opcache.dll, version: 8.0.13.0, time stamp: 0x61942d4a
Exception code: 0xc0000005
Fault offset: 0x000000000012a7cd
Faulting process id: 0x8b38
Faulting application start time: 0x01d7e63c092eb6ad
Faulting application path: C:\Program Files\PHP\v8.0\php-cgi.exe
Faulting module path: C:\Program Files\PHP\v8.0\ext\php_opcache.dll
Report Id: c9a1f978-17d7-4a3f-a340-3051ebe97f58
Faulting package full name:
Faulting package-relative application ID:
---
Fault bucket 1348990199055715320, type 4
Event Name: APPCRASH
Response: Not available
Cab Id: 0
Problem signature:
P1: php-cgi.exe
P2: 8.0.13.0
P3: 619429f5
P4: php_opcache.dll
P5: 8.0.13.0
P6: 61942d4a
P7: c0000005
P8: 000000000012a7cd
P9:
P10:
Attached files:
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER8F67.tmp.dmp
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER8FE5.tmp.WERInternalMetadata.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER9005.tmp.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER9019.tmp.csv
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER9039.tmp.txt
These files may be available here:
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_php-cgi.exe_2058cbb22b56eff0f71936402f536fd764c1aa4d_4a81e604_b0659449
Analysis symbol:
Rechecking for solution: 0
Report Id: c9a1f978-17d7-4a3f-a340-3051ebe97f58
Report Status: 268435456
Hashed bucket: 407a7897610279d7c2b8937054330bf8
Cab Guid: 0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81679&edit=1