Page MenuHomePhabricator

PHP Warning: preg_match(): Compilation failed: parentheses are too deeply nested at offset 1900
Open, Needs TriagePublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Warning: preg_match(): Compilation failed: parentheses are too deeply nested at offset 1900
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.25/extensions/Scribunto/includes/Engines/LuaCommon/UstringLibrary.php(724)
#0[internal function]MediaWiki\Exception\MWExceptionHandler::handleError(int, string, string, int)
#1/srv/mediawiki/php-1.44.0-wmf.25/extensions/Scribunto/includes/Engines/LuaCommon/UstringLibrary.php(724)preg_match(string, string, null, int, int)
#2/srv/mediawiki/php-1.44.0-wmf.25/extensions/Scribunto/includes/Engines/LuaSandbox/LuaSandboxCallback.php(31)MediaWiki\Extension\Scribunto\Engines\LuaCommon\UstringLibrary->ustringMatch(string, string)
#3[internal function]MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxCallback->__call(string, array)
#4/srv/mediawiki/php-1.44.0-wmf.25/extensions/Scribunto/includes/Engines/LuaSandbox/LuaSandboxInterpreter.php(137)LuaSandboxFunction->call(LuaSandboxFunction, LuaSandboxFunction)
#5/srv/mediawiki/php-1.44.0-wmf.25/extensions/Scribunto/includes/Engines/LuaCommon/LuaEngine.php(464)MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxInterpreter->callFunction(LuaSandboxFunction, LuaSandboxFunction, LuaSandboxFunction)
#6/srv/mediawiki/php-1.44.0-wmf.25/extensions/Scribunto/includes/ApiScribuntoConsole.php(125)MediaWiki\Extension\Scribunto\Engines\LuaCommon\LuaEngine->runConsole(array)
#7/srv/mediawiki/php-1.44.0-wmf.25/extensions/Scribunto/includes/ApiScribuntoConsole.php(91)MediaWiki\Extension\Scribunto\ApiScribuntoConsole->runConsole(array)
#8/srv/mediawiki/php-1.44.0-wmf.25/includes/api/ApiMain.php(2005)MediaWiki\Extension\Scribunto\ApiScribuntoConsole->execute()
#9/srv/mediawiki/php-1.44.0-wmf.25/includes/api/ApiMain.php(947)MediaWiki\Api\ApiMain->executeAction()
#10/srv/mediawiki/php-1.44.0-wmf.25/includes/api/ApiMain.php(918)MediaWiki\Api\ApiMain->executeActionWithErrorHandling()
#11/srv/mediawiki/php-1.44.0-wmf.25/includes/api/ApiEntryPoint.php(152)MediaWiki\Api\ApiMain->execute()
#12/srv/mediawiki/php-1.44.0-wmf.25/includes/MediaWikiEntryPoint.php(202)MediaWiki\Api\ApiEntryPoint->execute()
#13/srv/mediawiki/php-1.44.0-wmf.25/api.php(44)MediaWiki\MediaWikiEntryPoint->run()
#14/srv/mediawiki/w/api.php(3)require(string)
#15{main}
Impact
Notes

Details

Request URL
https://en.wiktionary.org/w/api.php
Related Changes in Gerrit:

Event Timeline

Bad user input from some ustring pattern in some Lua module (or possibly the console). Possibly a user testing something.

Probably the relevant code should silence the error here - it already indicates to the user the match failed.

There's already a generous limit of 10_000 bytes for the pattern length. But it's not clear if it's possible to check the nesting depth without executing the regex. Else silencing the error might the better option.

$p = str_repeat('(', 200) . str_repeat(')', 200);
$p2 = str_repeat('(', 300) . str_repeat(')', 300);

preg_match("/^$p$/", "foo"); // No error
preg_match("/^$p2$/", "foo"); // Compilation failed: parentheses are too deeply nested at offset 

Change #1217455 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[mediawiki/extensions/Scribunto@master] UstringLibrary: Silence preg_match warnings

https://gerrit.wikimedia.org/r/1217455