Jeff-Lewis / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

preg_replace_callback crashes on PHP 5.1.6 #62

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Minify version: 2.1.0
PHP version: 5.1.6

What steps will reproduce the problem?
1. Minify the attached CSS file

Expected output: A minified CSS

Actual output: Nothing, Apache (2.0.61) crashes

* When I switch to PHP 5.2.5, it works fine.
* When I comment the "remove ws in selectors", it works.
* _selectorsCB is not called.

Hi,

Even if I can use PHP 5.2.5, I have to develop with PHP 5.1.6.
Can you fix this ?

Thanks in advance

Original issue reported on code.google.com by coelho....@gmail.com on 15 Oct 2008 at 2:03

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for attaching the problematic CSS file. I'll look into this.

Original comment by mrclay....@gmail.com on 15 Oct 2008 at 3:12

GoogleCodeExporter commented 9 years ago
Maybe it can help you : I have other CSS files in my app but they don't crash.

Original comment by coelho....@gmail.com on 15 Oct 2008 at 3:15

GoogleCodeExporter commented 9 years ago
Have you run the unit test test_Minify_CSS.php ? Does it cause the same crash?

Original comment by mrclay....@gmail.com on 16 Dec 2008 at 4:59

GoogleCodeExporter commented 9 years ago
Apache crashs even if I comment the "remove ws in selectors".

Original comment by coelho....@gmail.com on 17 Dec 2008 at 11:26

GoogleCodeExporter commented 9 years ago
I think moving to a port of YUIC's CSSmin will be much less memory/PCRE 
intensive.

Original comment by mrclay....@gmail.com on 23 Apr 2010 at 3:06

GoogleCodeExporter commented 9 years ago
Issue 218 has been merged into this issue.

Original comment by mrclay....@gmail.com on 31 Jan 2011 at 2:36

GoogleCodeExporter commented 9 years ago
I am having the same issue with WAMP running:
 - Apache 2.2.22 
 - PHP 5.4.3
 - Minify 2.1.5 (Downloaded from: https://code.google.com/p/minify/downloads/detail?name=minify-2.1.5.zip&can=2&q=)

The error that gets's sent to the browser is:
This webpage is not available
The webpage at http://localhost/min_unit_tests/test_Minify_css.php might be 
temporarily down or it may have moved permanently to a new web address.
Error 103 (net::ERR_CONNECTION_ABORTED): Unknown error.

The code that fails is in:
C:\wamp\www\min\lib\Minify\CSS\Compressor.php

The specific code is:
// remove ws in selectors
$css = preg_replace_callback('/
        (?:              # non-capture
            \\s*
            [^~>+,\\s]+  # selector part
            \\s*
            [,>+~]       # combinators
        )+
        \\s*
        [^~>+,\\s]+      # selector part
        {                # open declaration block
    /x'
    ,array($this, '_selectorsCB'), $css);

It happens when processing the following css:
C:\wamp\www\min_unit_tests\_test_files\css\issue62.css

Has there been a resolution to this?

Regards,

Scott

Original comment by slaugh...@mistro.ag on 3 May 2013 at 1:11

GoogleCodeExporter commented 9 years ago
Further testing reveals that it seems to have something to do with the total 
number of comma space combinations in the file.  
Eg;
font-family: Verdana, Arial, Lucida, Tahoma;

If I remove all css from line 451 the end of the issue62.css file, I get no 
error.
However if I then add another 3 comma space combinations to any font-family 
attribute in the file I get the error again.
Eg;
font-family: Verdana, Arial, Lucida, Tahoma, Algerian, Andalus, Aparajita;

Regards,

Scott

Original comment by slaugh...@mistro.ag on 3 May 2013 at 2:40

GoogleCodeExporter commented 9 years ago
Ok, I have solved the issue!!!  Hopefully this will save someone else out there 
the time it took me to track this down:

After more research on this I found the following page:
https://bugs.php.net/bug.php?id=25754

Which led me to this page:
https://bugs.php.net/bug.php?id=47689

Which led me to this page:
http://httpd.apache.org/docs/2.2/mod/mpm_common.html#ThreadStackSize

And after doing a quick google I found this page:
http://stackoverflow.com/questions/5058845/how-do-i-increase-the-stack-size-for-
apache-running-under-windows-7

and In Answer 4 he gives the following example of what to add to the apache 
http.conf:
<IfModule mpm_winnt_module>
   ThreadStackSize 8388608
</IfModule>

I did this and now it works.

So in the end it was not an issue with minify, or php's preg_replace_callback, 
it was an issue with the Stack Size set in apache.

I hope this saves someone some time ;-)

Regards,

Scott

Original comment by slaugh...@mistro.ag on 3 May 2013 at 4:38

GoogleCodeExporter commented 9 years ago
wow... thank you Scott!!! :D :D :D :D

Original comment by ceba...@gmail.com on 25 Jun 2013 at 5:26