php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80014 PHP 8.0 beta2 crashes with default JIT flags due to hardware incompatibility
Submitted: 2020-08-24 14:44 UTC Modified: 2020-09-20 04:22 UTC
From: buschmann at nidsa dot net Assigned: dmitry (profile)
Status: No Feedback Package: JIT
PHP Version: 8.0.0beta2 OS: Windows 10 Pro 64bit
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-08-24 14:44 UTC] buschmann at nidsa dot net
Description:
------------
During the test of PHP 8 on all our applications I changed my development machine from PHP 7.4.9 to PHP 8.

The overall configuration is the same as on the test server.

PHP crashes immediatly when running any script (opcache_gui.php for example).

The configuration for JIT was as recommended:

opcache.jit_buffer_size=16M
opcache.jit=1205

In the apache error log the following showed up:

[Sun Aug 23 16:10:14.639607 2020] [mpm_winnt:notice] [pid 13272:tid 904] AH00428: Parent: child process 12228 exited with status 3221225501 -- Restarting.

Error 3221225501 is 0xc000001d and means "Illegal instruction"

The root cause is that the crashing machine has no AVX instructions available (Celeron G1840) and opcache.jit was set at 1205 where the "1" indicates "enable AVX instruction generation" as mentioned in the WIKI.

It is quite common to encounter machines with no AVX instructions: Celerons, ATOM, elder Server generations such as XEON x5570, non-x86-architectures etc.

It should be possible to use the same configuration on different hardware without a specific change.

The optimization parameter C=1 (enable AVX instruction generation) should not always generate AVX-instructions, but only when they are available in the hardware and otherwise fall back to non-AVX-JIT.

From the WIKI it is not clear, which AVX instruction set is used and required for this optimization (AVX-1? or AVX2?, AVX512 can be ruled out for now).

This error disappeared by setting opcache.jit=0205

PHP should detect the capabilities of the hardware before using unsupported advanced CPU optimization Flags.


Environment:
- Windows 10 64bit Pro
- Apache 2.46 64bit from apachelounge
- php 8 beta2 64bit thread safe from php.net QA download
- php loaded as a module with php_module


Actual result:
--------------
Crash dump follows:


Report for httpd__PID__10812__Date__08_24_2020__Time_04_00_39PM__171__Second_Chance_Exception_C000001D.dmp





Type of Analysis Performed Crash Analysis 
Machine Name WINHB16 
Operating System Windows 10 - 18363 
Number Of Processors 2 
Process ID 10812 
Process Image N:\Apache\Apache24\bin\httpd.exe 
Command Line httpd -X 
System Up-Time 9 day(s) 22:20:25 
Process Up-Time 00:01:26 
Processor Type X64 
Process Bitness 64-Bit 



Faulting Thread




Entry point   libhttpd!ap_run_generate_log_id+3ab0 
Create time   24.08.2020 15:59:14 
Time spent in user mode   0 Days 0:0:0.0 
Time spent in kernel mode   0 Days 0:0:0.0 






    Arg 1

    Arg 2

    Arg 3

    Arg 4

  Source

0x00001000`0300fe2e     0000237`24a95000     0000237`245e42e0     0000237`24a95000     0000237`24a68000    
0x00000237`24a15300     0000237`245e42e0     0000237`24a95000     0000237`24a68000     0000000`00000003    
0x00000237`24a95000     0000237`24a95000     0000237`24a68000     0000000`00000003     0000000`00000000    
0x00000237`245e42e0     0000237`24a68000     0000000`00000003     0000000`00000000     0000000`00000000    
0x00000237`24a95000     0000000`00000003     0000000`00000000     0000000`00000000     0000237`24a90660    
0x00000237`24a68000     0000000`00000000     0000000`00000000     0000237`24a90660     0000237`245e42e0    
0x00000003     0000000`00000000     0000237`24a90660     0000237`245e42e0     0000000`00000000    






CLR Information






Exception Information


In httpd__PID__10812__Date__08_24_2020__Time_04_00_39PM__171__Second_Chance_Exception_C000001D.dmp the assembly instruction at 0x00001000`0300fe2e which does not correspond to any known native module in the process has caused an unknown exception (0xc000001d) on thread 98

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-04 13:45 UTC] nikic@php.net
-Assigned To: +Assigned To: dmitry
 [2020-09-04 13:45 UTC] nikic@php.net
I agree that we should be picking avx instructions based on cpuid. @dmitry: What is the reason for having this as a user-configurable option at all?
 [2020-09-07 09:38 UTC] dmitry@php.net
-Status: Assigned +Status: Feedback
 [2020-09-07 09:38 UTC] dmitry@php.net
AVX code generation should be automatically disabled when unsupported:
https://github.com/php/php-src/blob/master/ext/opcache/jit/zend_jit_x86.dasc#L2710

I think, something is wrong with CPUID on Windows.
What compiler do you use to build PHP?
Can you set breakpoint on "zend_jit_setup" and check the content of "cpuinfo" variable in debugger?

@nikic it's good to have an ability of manual switch at least for testing.
 [2020-09-07 10:01 UTC] buschmann at nidsa dot net
-Status: Feedback +Status: Assigned
 [2020-09-07 10:01 UTC] buschmann at nidsa dot net
As noted in the original message I use the QA download from php web site.

I have no environment to compile/debug php myself.
 [2020-09-07 12:29 UTC] nikic@php.net
My first suspicion here was that we call zend_jit_setup before zend_cpu_startup, but at least on linux that's not the case.

One thing I noticed though is that if opcache.jit is changes at runtime and we call zend_jit_config, nothing will unset the AVX flag at that point anymore.
 [2020-09-10 06:34 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=00076ef2b90e2c6ff832d56648d47bddb4d44115
Log: Attempt to fix bug #80014 (PHP 8.0 beta2 crashes with default JIT flags due to hardware incompatibility)
 [2020-09-10 06:34 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2020-09-10 06:37 UTC] dmitry@php.net
-Status: Closed +Status: Feedback
 [2020-09-10 06:37 UTC] dmitry@php.net
Please check if commit https://github.com/php/php-src/commit/00076ef2b90e2c6ff832d56648d47bddb4d44115 fixes the problem. (It should be included into RC1).
 [2020-09-20 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 12:01:27 2024 UTC