Last modified: 2011-03-14 16:25:08 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T29449, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 27449 - Regex in JavascriptDistiller causes stack overflow on windows
Regex in JavascriptDistiller causes stack overflow on windows
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.18.x
All All
: Normal normal (vote)
: ---
Assigned To: Trevor Parscal
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-16 11:17 UTC by P.Copp
Modified: 2011-03-14 16:25 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description P.Copp 2011-02-16 11:17:14 UTC
MW 1.18 causes apache to crash on windows on every load.php request. This is due to a regex in JavascriptDistiller with bad backtracking behavior:

'/\\/\\*(.|[\\r\\n])*?\\*\\//'

Replacing the  (.|[\\r\\n]) part with \\C solves the problem
Comment 2 Liangent 2011-02-16 11:21:28 UTC
I see nothing wrong with the regex itself... is this a configuration error or a bug in PHP?
Comment 3 Aaron Schulz 2011-02-16 11:22:48 UTC
(In reply to comment #2)
> I see nothing wrong with the regex itself... is this a configuration error or a
> bug in PHP?

See comment #1 and http://www.mediawiki.org/wiki/Apache_configuration#Thread_stack_size. It's a default config issue in apache.
Comment 4 P.Copp 2011-02-16 11:32:11 UTC
(In reply to comment #1)
> See
> http://old.nabble.com/ResourceLoader-%2B-Windows-%2B-PHP-bug-47689-to30792236.html

Right, that's where I saw this. However, the suggested fix to increase the stack size only solves the symptom, while I don't think it's necessary to use regexes which need recursion depth proportional to the length of the string passed.
Comment 5 Aaron Schulz 2011-02-16 11:37:56 UTC
(In reply to comment #4)
> (In reply to comment #1)
> > See
> > http://old.nabble.com/ResourceLoader-%2B-Windows-%2B-PHP-bug-47689-to30792236.html
> 
> Right, that's where I saw this. However, the suggested fix to increase the
> stack size only solves the symptom, while I don't think it's necessary to use
> regexes which need recursion depth proportional to the length of the string
> passed.

Fair enough. I am a bit worried that the more things use RL, the more easily it will overflow. It's something to be looked at.

It apparently needs the capture (of the code comments), which will get worse an worse as the input lengthens.
Comment 6 Roan Kattouw 2011-02-20 20:03:32 UTC
Tim recently changed the regex to be multiline and use . instead of (.|[\r\n]). Does this fix the issue?
Comment 7 Trevor Parscal 2011-02-22 19:01:58 UTC
Just to help keep things in sync...

In bug #27528 an entirely new alternative to JavaScriptDistiller called JavaScriptMinifier is proposed, which if used may close this bug.
Comment 8 P.Copp 2011-03-14 16:25:08 UTC
(In reply to comment #6)
> Tim recently changed the regex to be multiline and use . instead of (.|[\r\n]).
> Does this fix the issue?
Yes.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links