Re: Re: CLI Crash Bug

Jan Ehrhardt <[email protected]>
Newsgroups gmane.comp.php.windows
Message-ID <[email protected]>
Eric Stenson in php.windows (Thu, 25 Jul 2013 18:35:25 +0000):
>I've filed bug https://bugs.php.net/bug.php?id=65338 to track this
>issue.  The root cause of the AV is when more than one module hooks the
>interned strings, a "wrong" value will be left in
>CG(interned_strings_start), which the Zend core thinks contains the
>value that it alloc'd during zend_interned_strings_init().
>
>I've added a potential fix for the Zend folks to consider.  It's
>slightly less harsh than the workaround provided by Jan.  ;)

The problem is so obvious, that I am surprised it did not com to surface
earlier. And the patch is elegant: do not assume interned_strings_start
is still the same, but free only the memory that you owned at startup.

In fact, the patch should be backported to PHP 5.4 as well. I do not
have a use case for X86, but I ran into the same problem woth PHP 5.4
X64. I know this is no official version, but as an illustration of the
problem it still is useful.

Compare these two builds:
https://dl.dropboxusercontent.com/u/8954372/php-5.4.17-nts-Win32-VC9-x64.zip
https://dl.dropboxusercontent.com/u/8954372/php-5.4.17-nts-Win32-VC9-x64_patched.zip

Try the unpatched one first. Put this in your php.ini:

extension=php_wincache.dll
zend_extension=ext/php_opcache.dll

zend_opcache.memory_consumption=128
zend_opcache.interned_strings_buffer=8
zend_opcache.max_accelerated_files=4000
zend_opcache.revalidate_freq=60
zend_opcache.fast_shutdown=1
zend_opcache.enable_cli=1

wincache.ocenabled=0
wincache.fcenabled=0	
wincache.ucachesize=768
wincache.enablecli=1
session.savehandler=wincache

Then run from the commandline in your php-directory:
php-cgi.exe -m

php-cgi will crash after showing the loaded modules. Debugging with VC9
gave this result: http://x32.elijst.nl/zendfree.png
Quite another breakpoint as in the PHP 5.5 example, but with the same
cause: freeing memory you do not own.

In the patched build I backported Eric's patch for zend_string.c to PHP
5.4. Result: no crash anymore.

A last remark: i do not think the problem is Windows specific. This is
exectly the same problem, but with the combination of opcache and apc:
http://svn.php.net/viewvc?view=revision&revision=330859

Jan

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.