Skip to content

console eternal loop #20277

@webmake

Description

@webmake

Recently I had unexpected output with console repeating lines, when pressing ctrl+d, so it enters to eternal loop. After some time of debugging I found "initiator" of buggy workflow:
vendor/symfony/console/Helper/QuestionHelper.php:133

            $ret = fgets($inputStream, 4096);
            if (false === $ret) {
                throw new \RuntimeException('Aborted');
            }

which according http://stackoverflow.com/a/19228847 states:
"On Linux, Ctrl + D generates EOF, so you need to check the return value of fgets() every time. When EOF is encountered, fgets() returns a null pointer"

Furthermore, imho throw exception shouldn't be suppressed here in such situations
vendor/symfony/console/Helper/QuestionHelper.php:391

    while (null === $attempts || $attempts--) {
        if (null !== $error) {
            $this->writeError($output, $error);
        }

        try {
            return call_user_func($question->getValidator(), $interviewer());
        } catch (\Exception $error) {
        }
    }

This eternal loop has came with the case then $attempts is null:
vendor/symfony/console/Style/SymfonyStyle.php:204 in method ask() when initiated Question object had default undefined (aka null value) $attempts parameter..

symfony/console
version: "v3.1.5"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions