Page MenuHomePhabricator

Blocks of added lines have an off-by-one error when porting phantom comments
Closed, ResolvedPublic

Description

See PHI2005. To reproduce this:

  • Create a revision with the diff below.
  • Leave an inline comment in the middle of the block of added lines.
  • Update the revision with the same diff.

Expected behavior:

  • Comment sticks to the original line when ported forward.

Actual behavior:

  • Comment jumps up one line.

(This diff is just one I happened to have on hand, the content is largely arbitrary. Any diff which adds a block of lines should produce similar behavior.)

diff --git a/support/startup/PhabricatorStartup.php b/support/startup/PhabricatorStartup.php
index 2ef257091f..bf66f8839b 100644
--- a/support/startup/PhabricatorStartup.php
+++ b/support/startup/PhabricatorStartup.php
@@ -400,6 +400,24 @@ final class PhabricatorStartup {
     // a UTF-8 locale we can encounter problems when launching subprocesses
     // which receive UTF-8 parameters in their command line argument list.
     @setlocale(LC_ALL, 'en_US.UTF-8');
+
+    $config_map = array(
+      // See PHI1894. Keep "args" in exception backtraces.
+      '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: Arcanist applies a similar set of startup options for CLI
+      // environments in "init-script.php". Changes here may also be
+      // appropriate to apply there.
+    );
+
+    foreach ($config_map as $config_key => $config_value) {
+      ini_set($config_key, $config_value);
+    }
   }

This appears to arise from a disagreement between lower-level code and display-level code about what an "offset" field means.

Related Objects