From e95afd1d005c389ef6215a809f6f94007826467c Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 18 Feb 2021 11:16:01 -0800 Subject: [PATCH] Apply "pcre.*_limit" config options at startup in CLI environments Summary: Ref T13100. Ref T13586. These options have been in production for a while and seem to consistently improve behavior, downgrading segfaults to runtime errors. Make them global options for all CLI environments. See next change for web enviornments. Test Plan: Ran `arc`. Maniphest Tasks: T13586, T13100 Differential Revision: https://secure.phabricator.com/D21566 --- support/init/init-script.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/support/init/init-script.php b/support/init/init-script.php index 9b67daef..ad40b8bd 100644 --- a/support/init/init-script.php +++ b/support/init/init-script.php @@ -56,6 +56,15 @@ function __arcanist_init_script__() { // inspect "args", and this option generally obscures useful debugging // information without any benefit in the context of Phabricator. 'zend.exception_ignore_args' => 0, + + // See T13100. We'd like the regex engine to fail, rather than segfault, + // if handed a pathological regular expression. + 'pcre.backtrack_limit' => 10000, + 'pcre.recusion_limit' => 10000, + + // NOTE: Phabricator applies a similar set of startup options for Web + // environments in "PhabricatorStartup". Changes here may also be + // appropriate to apply there. ); foreach ($config_map as $config_key => $config_value) { @@ -106,8 +115,6 @@ function __arcanist_init_script__() { PhutilErrorHandler::initialize(); - PhutilErrorHandler::initialize(); - // If "variables_order" excludes "E", silently repair it so that $_ENV has // the values we expect. PhutilExecutionEnvironment::repairMissingVariablesOrder();