Edit report at https://bugs.php.net/bug.php?id=74833&edit=1
ID: 74833
Updated by: nikic@php.net
Reported by: mike dot fellows at shaw dot ca
Summary: Random crashes, seemingly related to
DateTimeImmutable and mod_php
Status: Open
Type: Bug
Package: Apache2 related
Operating System: Windows 7 64 bit, MacOs, Linux
PHP Version: 7.0.1 to 7.1.6
Block user comment: N
Private report: N
New Comment:
Are you using opcache? Are you using ZTS builds?
If the answers are no and yes, this sounds like it might be a persistent string corruption issue, in
which case you should check whether using a PHP 7.2 alpha resolves the issue.
Previous Comments:
------------------------------------------------------------------------
[2017-06-30 23:09:32] mike dot fellows at shaw dot ca
FWIW here is the Visual Studio:
The thread 0x346c has exited with code 0 (0x0).
The thread 0x359c has exited with code 0 (0x0).
The thread 0x804 has exited with code 0 (0x0).
'httpd.exe' (Win32): Unloaded 'C:\Windows\System32\security.dll'
Unhandled exception at 0x0000000077346789 (ntdll.dll) in httpd.exe: 0xC0000005: Access violation
reading location 0x00000AEE2AF79F18.
The thread 0x37e0 has exited with code 0 (0x0).
'httpd.exe' (Win32): Unloaded 'C:\Windows\System32\1033\msodbcsqlr13.rll'
Exception thrown at 0x0000000077346789 (ntdll.dll) in httpd.exe: 0xC0000005: Access violation
reading location 0x00000AEE2AF79F18.
Unhandled exception at 0x0000000077346789 (ntdll.dll) in httpd.exe: 0xC0000005: Access violation
reading location 0x00000AEE2AF79F18.
Exception thrown at 0x0000000077346789 (ntdll.dll) in httpd.exe: 0xC0000005: Access violation
reading location 0x00000AEE2AF79F18.
Unhandled exception at 0x0000000077346789 (ntdll.dll) in httpd.exe: 0xC0000005: Access violation
reading location 0x00000AEE2AF79F18.
Exception thrown at 0x0000000077346789 (ntdll.dll) in httpd.exe: 0xC0000005: Access violation
reading location 0x00000AEE2AF79F18.
... (repeating many times)
------------------------------------------------------------------------
[2017-06-30 22:58:27] mike dot fellows at shaw dot ca
I have managed to gather a Call Stack when Apache crashes. Here are the messages from the Apache
error log immediately before the crash:
[Fri Jun 30 15:44:18.309323 2017] [php7:error] [pid 3444:tid 2756] [client ::1:10998] PHP Fatal
error: Class Cake\\Chronos\\MutableDateTime contains 1 abstract method and must therefore be
declared abstract or implement the remaining methods (Cake\\Chronos\\ChronosInterface::__wakeup) in
C:\\genesis\\vendor\\cakephp\\chronos\\src\\MutableDateTime.php on line 51, referer: <snip>
[Fri Jun 30 15:44:18.310323 2017] [php7:error] [pid 3444:tid 2764] [client ::1:10995] PHP Fatal
error: Class Cake\\Chronos\\MutableDateTime contains 1 abstract method and must therefore be
declared abstract or implement the remaining methods (Cake\\Chronos\\ChronosInterface::__wakeup) in
C:\\genesis\\vendor\\cakephp\\chronos\\src\\MutableDateTime.php on line 51, referer: <snip>
[Fri Jun 30 15:44:18.328325 2017] [php7:error] [pid 3444:tid 2772] [client ::1:10997] PHP Fatal
error: Class Cake\\Chronos\\MutableDate contains 2 abstract methods and must therefore be declared
abstract or implement the remaining methods (Cake\\Chronos\\ChronosInterface::getTimezone,
Cake\\Chronos\\ChronosInterface::__wakeup) in
C:\\genesis\\vendor\\cakephp\\chronos\\src\\MutableDate.php on line 50, referer: <snip>
Here is the Call Stack from Visual Studio:
ntdll.dll!RtlSizeHeap() Unknown
AcXtrnal.dll!NS_FaultTolerantHeap::APIHook_RtlFreeHeap(void *,unsigned long,void *) Unknown
ucrtbase.dll!free() Unknown
php7ts.dll!zend_hash_reverse_apply(_zend_array * ht, int(*)(_zval_struct *) apply_func) Line 1603 C
php7ts.dll!shutdown_executor() Line 376 C
php7ts.dll!zend_deactivate() Line 1001 C
php7ts.dll!php_request_shutdown(void * dummy) Line 1880 C
php7apache2_4.dll!php_handler(request_rec * r) Line 725 C
libhttpd.dll!000000007475e9e5() Unknown
libhttpd.dll!000000007475d7e0() Unknown
libhttpd.dll!000000007475a1e6() Unknown
mod_rewrite.so!00000000743753c8() Unknown
libhttpd.dll!000000007475e9e5() Unknown
libhttpd.dll!000000007475d7e0() Unknown
libhttpd.dll!000000007475a49a() Unknown
libhttpd.dll!000000007475a527() Unknown
libhttpd.dll!0000000074753b73() Unknown
libhttpd.dll!0000000074761885() Unknown
libhttpd.dll!0000000074761675() Unknown
libhttpd.dll!0000000074771734() Unknown
[External Code]
------------------------------------------------------------------------
[2017-06-30 18:32:46] mike dot fellows at shaw dot ca
Re-examining the Chronos issue linked and just improved the description of the PHP versions and OSes
impacted.
Please note that despite the Chronos issue being opened a couple of days ago, the original CakePHP
issue was opened almost a year ago. This has been a problem for some time.
------------------------------------------------------------------------
[2017-06-29 22:25:57] mike dot fellows at shaw dot ca
I just re-reviewed the linked Chronos issue and realized that one user has seen this with Apache and
suphp. So the problem is not exclusive to mod_php.
------------------------------------------------------------------------
[2017-06-29 22:12:15] mike dot fellows at shaw dot ca
Description:
------------
The CakePHP project includes a class called Chronos that extends DateTimeImmutable. It seems to
cause occasional random crashes when run through Apache and mod_php. In all cases described below
the same PHP software would run flawlessly most of the time, with occasional random crashes (no
changes to the PHP software between everything being OK and crashing).
The crashes have inconsistent symptoms and I have not been able to capture a backtrace. They are
possibly caused by instantiation of the Chronos class, although this is hard to prove. Symptoms
include:
- Complaints about the Chronos class containing abstract methods (when it doesn't). Once this
symptom appears it would continue in this state on page reload. Eventually Apache usually crashes
given enough page reloads, sometimes witht the zend_mm_heap corrupted mentioned below, somtimes not.
- Sometimes a "zend_mm_heap corrupted" message is placed in the log file followed by a
crash and Apache being restared.
- Sometimes Apache crashes with no log messages.
In all cases restarted Apache would "fix" the problem page for awhile.
I've run the same software using PHP's built in web server and not observed any crashes.
I connected Visual Studio 2015's debugger to the Apache process handling the request - but the
symptoms stopped once the debugger was connected.
Any suggestions for capturing backtraces would be welcome BTW. I'm currently running Apache
from Apache Lounge and PHP from php.net.
There is copious amounts of information about this bug found here:
https://github.com/cakephp/chronos/issues/147
It seems to have been reported with PHP version 7.0 and up. My experience has been on Windows 7,
but others have reported similar symptoms with Linux intalls (again with mod_php).
Test script:
---------------
Code can be inspected here for the Class:
https://github.com/cakephp/chronos/blob/master/src/Chronos.php
and here for its interface:
https://github.com/cakephp/chronos/blob/master/src/ChronosInterface.php
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74833&edit=1