Bug #80014 [Asn->Fbk]: PHP 8.0 beta2 crashes with default JIT flags due to hardware incompatibility

From: Date: Mon, 07 Sep 2020 09:38:29 +0000
Subject: Bug #80014 [Asn->Fbk]: PHP 8.0 beta2 crashes with default JIT flags due to hardware incompatibility
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228923@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80014&edit=1

 ID:                 80014
 Updated by:         dmitry@php.net
 Reported by:        buschmann at nidsa dot net
 Summary:            PHP 8.0 beta2 crashes with default JIT flags due to
                     hardware incompatibility
-Status:             Assigned
+Status:             Feedback
 Type:               Bug
 Package:            JIT
 Operating System:   Windows 10 Pro 64bit
 PHP Version:        8.0.0beta2
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2020-09-04 13:45:10] 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-08-24 16:29:36] cmb@php.net

Related To: Bug #80015

------------------------------------------------------------------------
[2020-08-24 14:44:36] 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

0x000010000300fe2e     000023724a95000     0000237245e42e0    
000023724a95000     0000237`24a68000    
0x0000023724a15300     0000237245e42e0     000023724a95000    
000023724a68000     0000000`00000003    
0x0000023724a95000     000023724a95000     000023724a68000    
000000000000003     0000000`00000000    
0x00000237245e42e0     000023724a68000     000000000000003    
000000000000000     0000000`00000000    
0x0000023724a95000     000000000000003     000000000000000    
000000000000000     0000237`24a90660    
0x0000023724a68000     000000000000000     000000000000000    
000023724a90660     0000237`245e42e0    
0x00000003     000000000000000     000023724a90660     0000237245e42e0    
000000000000000    






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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80014&edit=1


Thread (8 messages)

« previous php.bugs (#228923) next »