PHP segmentation fault on arc diff with empty explanation


#1

Observed Behavior:
Upon providing an empty explanation for linting exceptions, PHP spews memory allocation errors and segfaults.

Expected Behavior:
Prompt again (until a valid explanation is given) or exit gracefully.

Phabricator Version:

$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
$ arc version
arcanist 8b1be5b87f046ce513f011fbf795ea892f72f215 (8 Jun 2018)
libphutil 47c97f0c48429a25f35ca9b515c7b9e15889d77f (8 Jun 2018)
$ php --version
PHP 7.2.7 (cli) (built: Jun 22 2018 06:24:54) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Reproduction Steps:

$ cat .arclint
{
    "exclude": [
        "(\\.(pem|crt|mib)$)",
        "(^external-modules/)"
    ],
    "linters": {
        "stdtext": {
            "type": "text",
            "severity": {
               "2": "disabled",
               "3": "disabled"
            }
        },
        "find-conflicts": {
            "type": "merge-conflict"
        },
        "sane-filenames": {
            "type": "filename"
        },
        "permissions": {
            "type": "chmod"
        }
    }
}
$ arc diff
Linting...
>>> Lint for some/file:
[list of errors]
 LINT ERRORS  Lint raised errors!


Lint issued unresolved errors! Provide explanation to continue or press Enter
to abort.
    Explanation:

Hit Enter without any input.

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Warning:  Uncaught ArcanistUserAbortException: User aborted the workflow. in /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php:1438
Stacktrace:
#0 /opt/phabricator/libphutil/src/console/PhutilConsoleServer.php(88): ArcanistDiffWorkflow->handleServerMessage(Object(PhutilConsoleMessage))
#1 /opt/phabricator/libphutil/src/console/PhutilConsole.php(204): PhutilConsoleServer->handleMessage(Object(PhutilConsoleMessage))
#2 /opt/phabricator/libphutil/src/console/PhutilConsole.php(138): PhutilConsole->writeMessage(Object(PhutilConsoleMessage))
#3 /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php(1415): PhutilConsole->sendMessage(Array)
#4 /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php(1281): ArcanistDiffWorkflow->getErrorExcuse('lint', 'Lint issued unr...', '/home/<redacted>....')
#5 /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php(1211): ArcanistDiffWorkflow->runLint()
#6 /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php(483): ArcanistDiffWorkflow->runLi in /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php on line 1438
mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 12582912) (tried to allocate 18446744069414585384 bytes) in /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php on line 1438
PHP Stack trace:
PHP   1. {main}() /opt/phabricator/arcanist/scripts/arcanist.php:0
PHP   2. ArcanistDiffWorkflow->run() /opt/phabricator/arcanist/scripts/arcanist.php:394
PHP   3. ArcanistDiffWorkflow->runLintUnit() /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php:483
PHP   4. ArcanistDiffWorkflow->runLint() /opt/phabricator/arcanist/src/workflow/ArcanistDiffWorkflow.php:1211

This very same PHP stacktrace repeats endless times.