Bug #81033 [Opn]: "Interactive Mode" Shell Hangs Indefinitely

From: Date: Wed, 12 May 2021 07:40:21 +0000
Subject: Bug #81033 [Opn]: "Interactive Mode" Shell Hangs Indefinitely
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233798@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81033&edit=1 ID: 81033 Updated by: nikic@php.net Reported by: security at paragonie dot com Summary: "Interactive Mode" Shell Hangs Indefinitely Status: Open Type: Bug Package: *General Issues Operating System: Ubuntu Linux PHP Version: master-Git-2021-05-12 (Git) Block user comment: N Private report: N New Comment: To clarify how this works: If you have readline enabled, then "Interactive shell" is printed, and you get a normal interactive shell, where you can enter something and press enter to run it. If readline is not enabled, then "Interactive mode enabled" is printed, and PHP just reads from stdin. You can use this mode by entering something and then using Ctrl+D to close stdin. This is all pretty confusing, and the -a mode without readline seems pretty much useless to me. Maybe we should just completely disable -a if readline is not available? Previous Comments: ------------------------------------------------------------------------ [2021-05-12 04:06:33] requinix@php.net > I've rebuilt it --with-readline and now I'm getting a weird error I don't > understand, but it looks unrelated: It sure does look unrelated, and c945c39 just built successfully for me. Did you reuse the same build directory from before? Did you make clean/git clean it before the second build? > Interestingly, in my copy of PHP 8.0.x (provided by the ondrej packages for > Ubuntu), I see the following prompt: The relevant php_cli.c source [1] has changed some with 8.1, that is true: if (interactive) { if (cli_shell_callbacks.cli_shell_run) { printf("Interactive shell\n\n"); } else { printf("Interactive mode enabled\n\n"); /* Treat as non-interactive apart from the stdin input */ interactive = false; } With 8.0 and before, there were still two messages displayed [2]: "shell" if you had specifically libreadline or libedit support and "mode" if not. What about building the same 8.0.x version yourself? [1] https://github.com/php/php-src/blob/c945c39/sapi/cli/php_cli.c#L876 [2] https://github.com/php/php-src/blob/PHP-8.0.6/sapi/cli/php_cli.c#L867 ------------------------------------------------------------------------ [2021-05-12 02:19:23] security at paragonie dot com No, I did not --with-readline my ./configure command. Yes, this was from HEAD on the master branch on Github: commit hash c945c399aa8051ae24c727d73c1ea0989f4d14d7 I've rebuilt it --with-readline and now I'm getting a weird error I don't understand, but it looks unrelated: /usr/bin/ld: ext/reflection/php_reflection.o: in function `zim_ReflectionFiber___construct': /home/scott/tmp/php-src/ext/reflection/php_reflection.c:6770: undefined reference to `zend_ce_fiber' /usr/bin/ld: ext/reflection/php_reflection.o: in function `instanceof_function': /home/scott/tmp/php-src/Zend/zend_operators.h:71: undefined reference to `zend_ce_fiber' /usr/bin/ld: ext/reflection/php_reflection.o: in function `zim_ReflectionFiber___construct': /home/scott/tmp/php-src/ext/reflection/php_reflection.c:6779: undefined reference to `zend_ce_fiber' /usr/bin/ld: Zend/zend_execute_API.o: in function `init_executor': /home/scott/tmp/php-src/Zend/zend_execute_API.c:195: undefined reference to `zend_fiber_init' /usr/bin/ld: Zend/zend_default_classes.o: in function `zend_register_default_classes': /home/scott/tmp/php-src/Zend/zend_default_classes.c:42: undefined reference to `zend_register_fiber_ce' collect2: error: ld returned 1 exit status make: *** [Makefile:274: sapi/cli/php] Error 1 > The prompt you're expecting comes after an "Interactive shell" message. Interestingly, in my copy of PHP 8.0.x (provided by the ondrej packages for Ubuntu), I see the following prompt: $ php8.0 -a Interactive mode enabled php > ...Is this "Interactive mode enabled" / "Interactive shell" verbage something new to PHP 8.1? If that discrepancy isn't new, then readline might be a red herring, because it's working as expected when that prompt is displayed. ------------------------------------------------------------------------ [2021-05-12 02:08:18] requinix@php.net "Interactive mode enabled" means that it is reading from stdin but does not give you a full shell. The prompt you're expecting comes after an "Interactive shell" message. Did you build with readline support? I don't see a --with-readline in your configure command. Or anything else, for that matter. And just in case, what commit did you build from? Was it HEAD within the last ~16 hours? ------------------------------------------------------------------------ [2021-05-12 01:15:48] security at paragonie dot com Description: ------------ Currently, I get the following result when I try to start an interactive session: $ php -a Interactive mode enabled ...but it hangs forever without prompting at all. Using php -r works as expected: $ php -r "echo 'hello world', PHP_EOL;" $ php -v PHP 8.1.0-dev (cli) (built: May 11 2021 21:07:43) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.0-dev, Copyright (c) Zend Technologies The output of php -r "phpinfo();" is provided for completeness, although I do not think it's a configuration issue: https://gist.github.com/paragonie-security/92571c1121e4b16e019a82e810643bf6 Test script: --------------- N/A just run php -a after building from master ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81033&edit=1

« previous php.bugs (#233798) next »