Bug #65561 [Com]: Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4
Edit report at https://bugs.php.net/bug.php?id=65561&edit=1 ID: 65561 Comment by: craig dot mohrman at oracle dot com Reported by:craig dot mohrman at oracle dot com Summary:Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4 Status: Closed Type: Bug Package:opcache Operating System: Solaris 11 PHP Version:Irrelevant Assigned To:dmitry Block user comment: N Private report: N New Comment: To answer Terry's question: PS for Craig: (i) Does the Solaris compiler have a pragma/builtin equivalent to __alignof__, and what is the correct constant to use to test for the Solaris C compiler? 1) yes; Solaris Studio has http://docs.oracle.com/cd/E19205-01/820-4155/c.html Values are for this particular example: x86 32-bit = 4 x86 64-bit = 8 sparc 32-bit = 8 sparc 64-bit = 8 Previous Comments: [2013-08-29 06:36:13] dmi...@php.net The fix for this bug has been committed. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. [2013-08-29 06:32:31] dmi...@php.net Automatic comment on behalf of dmi...@zend.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=790db9ff9b95d9dfaf6720593517dc0368f1fe7f Log: Fixed bug #65561 (Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4). (Terry Ellison) [2013-08-27 16:39:39] Terry at ellisons dot org dot uk OK, I have got this as a repeatable bug on PHP 5.3.27 with OPcache installed on a std 32bit GCC LAMP VM -- if I force the dropping of the __alignof__ defines to default to sizeof (as happens configuring with the Solaris C compiler). The minimum test that fails is $ php -d zend_extension=../modules/opcache.so -d opcache.enable=1 -d opcache.enable_cli=1 = 2) #define ZEND_MM_ALIGNMENT (__alignof__ (mm_align_test)) #else #define ZEND_MM_ALIGNMENT (sizeof(mm_align_test)) #endif whereas zend_shared_alloc.h instead sets its own PLATFORM_ALIGNMENT instead of using ZEND_MM_ALIGNMENT: #if ZEND_GCC_VERSION >= 2000 # define PLATFORM_ALIGNMENT (__alignof__ (align_test)) #else # define PLATFORM_ALIGNMENT (sizeof(align_test)) #endif However, I'll try a 32-bit 5.3.27 on a LAMP stack and force this to see if I can track it down. PS for Craig: (i) Does the Solaris compiler have a pragma/builtin equivalent to __alignof__, and what is the correct constant to use to test for the Solaris C compiler? [2013-08-26 19:43:12] craig dot mohrman at oracle dot com Description: This is a place holder bug for anyone working with Solaris and php 5.3.27 I haven't tried the latest version of PHP so maybe this just goes away. I've documented this in a thread here: https://github.com/zendtech/ZendOptimizerPlus/issues/122 But the problem appears to be in php itself. This is compiling the Zend Opcache 7.0.2 from: http://pecl.php.net/package/ZendOpcache When compiling ZendOpcache with php 5.3.27 on Solaris 11 x86 with the Solaris Studio compiler (12.1) I'm seeing Overflown errors even with the most trivial of php programs. This is all being done in 32-bit. Sparc has no such issue. Works out of the box. As a workaround I'm patching ZEND_MM_ALIGNMENT: #define ZEND_MM_ALIGNMENT 8 #define ZEND_MM_ALIGNMENT_LOG2 3 to #define ZEND_MM_ALIGNMENT 4 #define ZEND_MM_ALIGNMENT_LOG2 2 over in PHP/Zend/Zend.m4 and everything works fine. I got this 4 when compiling php 5.3.27 with gcc 4.5. That comes up with ZEND_MM_ALIGNMENT=4 but when compiling with Solaris Studio I get ZEND_MM_ALIGNMENT=8. Oddly on Solaris sparc both Solaris Studio and gcc 4.5 come up with: ZEND_MM_ALIGNMENT=8 but that works fine. So see the actual patch below. This is not the solution but gets Zend Opcache working on Solaris x86. Test script: --- $ cat simple.php "; ?> Expected result: $ php -v PHP 5.3.27 (cli) (built: Aug 20 2013 11:05:05) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.2, Copyright (c) 1999-2013, by Zend Technologies with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH $ php -f simple.php y = 6 Actual result: -- $ php -f simple.php File /home/cmohrman/Public/PHP/simple.php func m_x_plus_b Block: 0-5 (6) unused Block: 6-6 (1) T0: 0 T1: 0 Opt Block: 0-5 (6) T0: 0 T1: 0 Opt Block: 0-5 (6) T
[PHP-BUG] Bug #65561 [NEW]: Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4
From: craig dot mohrman at oracle dot com Operating system: Solaris 11 PHP version: Irrelevant Package: opcache Bug Type: Bug Bug description:Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4 Description: This is a place holder bug for anyone working with Solaris and php 5.3.27 I haven't tried the latest version of PHP so maybe this just goes away. I've documented this in a thread here: https://github.com/zendtech/ZendOptimizerPlus/issues/122 But the problem appears to be in php itself. This is compiling the Zend Opcache 7.0.2 from: http://pecl.php.net/package/ZendOpcache When compiling ZendOpcache with php 5.3.27 on Solaris 11 x86 with the Solaris Studio compiler (12.1) I'm seeing Overflown errors even with the most trivial of php programs. This is all being done in 32-bit. Sparc has no such issue. Works out of the box. As a workaround I'm patching ZEND_MM_ALIGNMENT: #define ZEND_MM_ALIGNMENT 8 #define ZEND_MM_ALIGNMENT_LOG2 3 to #define ZEND_MM_ALIGNMENT 4 #define ZEND_MM_ALIGNMENT_LOG2 2 over in PHP/Zend/Zend.m4 and everything works fine. I got this 4 when compiling php 5.3.27 with gcc 4.5. That comes up with ZEND_MM_ALIGNMENT=4 but when compiling with Solaris Studio I get ZEND_MM_ALIGNMENT=8. Oddly on Solaris sparc both Solaris Studio and gcc 4.5 come up with: ZEND_MM_ALIGNMENT=8 but that works fine. So see the actual patch below. This is not the solution but gets Zend Opcache working on Solaris x86. Test script: --- $ cat simple.php "; ?> Expected result: $ php -v PHP 5.3.27 (cli) (built: Aug 20 2013 11:05:05) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.2, Copyright (c) 1999-2013, by Zend Technologies with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH $ php -f simple.php y = 6 Actual result: -- $ php -f simple.php File /home/cmohrman/Public/PHP/simple.php func m_x_plus_b Block: 0-5 (6) unused Block: 6-6 (1) T0: 0 T1: 0 Opt Block: 0-5 (6) T0: 0 T1: 0 Opt Block: 0-5 (6) T0: 0 T1: 0 Opt Block: 0-5 (6) T0: 0 T1: 0 Out Block: 0-5 (6) File /home/cmohrman/Public/PHP/simple.php func main Block: 0-11 (12) unused T0: 0 T1: 0 T2: 0 T3: 0 T4: 0 T5: 0 [Fri Aug 9 11:10:45 2013] Script: '/home/cmohrman/Public/PHP/simple.php' --- ./Optimizer/block_pass.c(2053) : Block 0x0935e970 status: Beginning: OK (allocated on ./Optimizer/block_pass.c:1911, 6 bytes) Start: OK End: Overflown (magic=0x instead of 0x530646BC) 1 byte(s) overflown --- Opt Block: 0-11 (12) [Fri Aug 9 11:10:45 2013] Script: '/home/cmohrman/Public/PHP/simple.php' --- ./Optimizer/block_pass.c(1220) : Block 0x0935fa70 status: Beginning: OK (allocated on ./Optimizer/block_pass.c:631, 24 bytes) Start: OK End: Overflown (magic=0xFFB4 instead of 0x530646BC) At least 4 bytes overflown --- T0: 0 T1: 0 T2: 0 T3: 0 T4: 0 T5: 0 [Fri Aug 9 11:10:45 2013] Script: '/home/cmohrman/Public/PHP/simple.php' --- ./Optimizer/block_pass.c(2053) : Block 0x0935e9a8 status: Beginning: OK (allocated on ./Optimizer/block_pass.c:1911, 6 bytes) Start: OK End: Overflown (magic=0x instead of 0x530646BC) 1 byte(s) overflown --- Opt Block: 1-11 (11) [Fri Aug 9 11:10:45 2013] Script: '/home/cmohrman/Public/PHP/simple.php' --- ./Optimizer/block_pass.c(1220) : Block 0x0935fc80 status: Beginning: OK (allocated on ./Optimizer/block_pass.c:631, 24 bytes) Start: OK End: Overflown (magic=0xFFB4 instead of 0x530646BC) At least 4 bytes overflown --- T0: 0 T1: 0 T2: 0 T3: 0 T4: 0 T5: 0 [Fri Aug 9 11:10:45 2013] Script: '/home/cmohrman/Public/PHP/simple.php' --- ./Optimizer/block_pass.c(2053) : Block 0x0935e9e0 status: Beginning: OK (allocated on ./Optimizer/block_pass.c:1911, 6 bytes) Start: OK End: Overflown (magic=0x instead of 0x530646BC) 1 byte(s) overflown --- Opt Block: 1-11 (11) [Fri Aug 9 11:10:45 2013] Script: '/home/cmohrman/Public/PHP/simple.php' --- ./Optimizer/block_pass.c(1220) : Block 0x0935ea50 status: Beginning: OK (allocated on ./Optimizer/block_pass.c:631, 24 bytes) Start: OK End: Overflown (magic=0xFFB4 instead of 0x530646BC)