php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71024 Unable to use PHP 7.0 x64 side-by-side with PHP 5.6 x32 on the same server
Submitted: 2015-12-04 08:42 UTC Modified: 2015-12-10 18:13 UTC
From: pvasilevich at odin dot com Assigned: dmitry (profile)
Status: Closed Package: opcache
PHP Version: 7.0.0 OS: Windows
Private report: No CVE-ID: None
 [2015-12-04 08:42 UTC] pvasilevich at odin dot com
Description:
------------
STEPS TO REPRODUCE:
1) create site in IIS and configure it to use PHP 5.6 x86 for it.
2) create virtual directory (in this case the same pool user will be used for both PHP) and configure PHP 7.0 x64 on it.
3) browse site pages that handled by PHP 5.6 - everything works fine. Notice, that C:\Windows\Temp\ZendOPcache.MemoryBase@user file was created, and process php-cgi.exe holds handle to \BaseNamedObjects\ZendOPcache.SharedMemoryArea@user shared memory
4) then try to request pages under virtual directory handled by PHP 7.0




Expected result:
----------------
There could be several solutions and workarounds here. The most elegant and stable (appropriate for all following release as well) will be solution to differentiate shared memory names, and mmap_base files by name. Proposed solution is to include PHP version and architecture in file name and shared memory name, and mutex.

This can separate memory objects between different versions on servers, make it more stable.

The following request looks quite similar: https://github.com/zendtech/ZendOptimizerPlus/issues/109


Actual result:
--------------
500 Internal server error.
Looking at crash dump you can see:
000000de`14eeeea0 00007ff9`831433e1 php_opcache!accel_new_interned_string+0x27 [c:\php-sdk\php70dev\vc14\x64\php-7.0.0\ext\opcache\zendaccelerator.c @ 330]
000000de`14eeeee0 00007ff9`831466ca php_opcache!accel_use_shm_interned_strings+0x21 [c:\php-sdk\php70dev\vc14\x64\php-7.0.0\ext\opcache\zendaccelerator.c @ 395]
000000de`14eeef20 00007ff9`75847634 php_opcache!accel_startup+0x1fa [c:\php-sdk\php70dev\vc14\x64\php-7.0.0\ext\opcache\zendaccelerator.c @ 2662]
000000de`14eeef50 00007ff9`757ab25b php7!zend_extension_startup+0x24 [c:\php-sdk\php70dev\vc14\x64\php-7.0.0\zend\zend_extensions.c @ 176]
000000de`14eeef80 00007ff9`7544268c php7!zend_llist_apply_with_del+0x357ebb [c:\php-sdk\php70dev\vc14\x64\php-7.0.0\zend\zend_llist.c @ 171]
000000de`14eeefc0 00007ff7`21142787 php7!php_module_startup+0x95c [c:\php-sdk\php70dev\vc14\x64\php-7.0.0\main\main.c @ 2199]
000000de`14eef4c0 00007ff7`211448ec php_cgi!php_cgi_startup+0x17 [c:\php-sdk\php70dev\vc14\x64\php-7.0.0\sapi\cgi\cgi_main.c @ 918]
000000de`14eef4f0 00007ff7`21148d40 php_cgi!main+0x5bc [c:\php-sdk\php70dev\vc14\x64\php-7.0.0\sapi\cgi\cgi_main.c @ 1899]
000000de`14eefa20 00007ff9`93271611 php_cgi!__scrt_common_main_seh+0x124 [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl @ 264]
000000de`14eefa60 00007ff9`935a64ad kernel32!BaseThreadInitThunk+0xd
000000de`14eefa90 00000000`00000000 ntdll!RtlUserThreadStart+0x1d

In fact PHP 7 tries to use the same memory (looking for the same memory object name). Looks like because PHP 7 is 64-bit process, structure of the memory is different, that brings to crash.


Patches

bug71024_system_id_integration_2 (last revision 2015-12-07 14:29 UTC by ab@php.net)
bug71024_system_id_integration_1.patch (last revision 2015-12-07 14:13 UTC by ab@php.net)
bug71024_system_id_integration.patch (last revision 2015-12-07 13:44 UTC by ab@php.net)
use-different-opcache-memory-name-and-mmap-base-file.diff (last revision 2015-12-04 08:43 UTC by pvasilevich at odin dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-04 08:45 UTC] pvasilevich at odin dot com
You can check proposed path or pull request https://github.com/php/php-src/pull/1661
 [2015-12-05 14:47 UTC] laruence@php.net
-Assigned To: +Assigned To: dmitry
 [2015-12-05 14:47 UTC] laruence@php.net
I think this is a good improvement, @Dmitry what do you think?
 [2015-12-05 16:57 UTC] rasmus@php.net
Yeah, this makes sense to me.
 [2015-12-07 09:00 UTC] dmitry@php.net
Adding just a version may be not enough. The next request will ask for 32 vs 64 bit, ZTS vs non-ZTS, and so on.
We can add ZCG(system_id), that is actually MD5 sum generated by accel_gen_system_id(), based on php version and other sensitive information.
 [2015-12-07 09:02 UTC] ab@php.net
Making the mapping filename configurable per some environment variable or INI were probably the most flexible solution. Fe even same user could decide to not to share cache between two separate sites even running same PHP version.

But otherwise, ZTS factor should be counted in. Also, maybe major+minor could be enough instead of PHP_VERSION? Or nice were even the ACCELERATOR_VERSION instead of PHP_VERSION, but ACCELERATOR_VERSION seems to be not maintained much :)

Thanks.
 [2015-12-07 09:03 UTC] dmitry@php.net
It might be better to add ZCG(system_id).
 [2015-12-07 10:26 UTC] ab@php.net
Ups, that was just two minutes async between the comments :)

Of course, adding ZCG(system_id) for CreateFileMapping will do the most fine distinction for the compatibility of the cache. Dmitry, I could come up with a patch, or please let me know if i have to test one.

Thanks.
 [2015-12-07 13:44 UTC] ab@php.net
The following patch has been added/updated:

Patch Name: bug71024_system_id_integration.patch
Revision:   1449495892
URL:        https://bugs.php.net/patch-display.php?bug=71024&patch=bug71024_system_id_integration.patch&revision=1449495892
 [2015-12-07 14:13 UTC] ab@php.net
The following patch has been added/updated:

Patch Name: bug71024_system_id_integration_1.patch
Revision:   1449497625
URL:        https://bugs.php.net/patch-display.php?bug=71024&patch=bug71024_system_id_integration_1.patch&revision=1449497625
 [2015-12-07 14:29 UTC] ab@php.net
The following patch has been added/updated:

Patch Name: bug71024_system_id_integration_2
Revision:   1449498560
URL:        https://bugs.php.net/patch-display.php?bug=71024&patch=bug71024_system_id_integration_2&revision=1449498560
 [2015-12-07 14:33 UTC] ab@php.net
@pvasilevich please check the latest https://bugs.php.net/patch-display.php?bug_id=71024&patch=bug71024_system_id_integration_2&revision=latest , it appends ZCG(system_id) to mapping filename and to the mutex filename. That means having the most distinct names which will avoid any possible attaching to an incompatible cache.

Thanks.
 [2015-12-07 17:45 UTC] pvasilevich at odin dot com
Thanks Anatol,

your patch looks quite promising.
Is there any chance to get it in some nearest PHP 7.0.1 update?
 [2015-12-07 21:56 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7c981192eb26fbb93be767cd6b2dc765d370bbab
Log: Fixed bug #71024 Unable to use PHP 7.0 x64 side-by-side with PHP 5.6 x32 on the same server
 [2015-12-07 21:56 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2015-12-10 18:13 UTC] ab@php.net
Pavel, please test 7.0.1RC1, the patch is included. I'm intended to backport it to 5.6.

Thanks.
 [2015-12-11 03:03 UTC] pvasilevich at odin dot com
Checked on 7.0.1RC1 - works fine.
 [2016-07-20 11:34 UTC] davey@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7c981192eb26fbb93be767cd6b2dc765d370bbab
Log: Fixed bug #71024 Unable to use PHP 7.0 x64 side-by-side with PHP 5.6 x32 on the same server
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC