Bug #71094 [NEW]: readline_completion_function corrupts static array on (second) TAB
| From: | ml at visu dot li | Date: | Fri, 11 Dec 2015 14:54:32 +0000 |
| Subject: | Bug #71094 [NEW]: readline_completion_function corrupts static array on (second) TAB | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-197793@lists.php.net to get a copy of this message | ||
From: ml at visu dot li
Operating system: Linux
PHP version: 7.0.0
Package: Readline related
Bug Type: Bug
Bug description:readline_completion_function corrupts static array on (second) TAB
Description:
------------
Module: readline
Function: readline_completion_function
Version: PHP 7.0.0 (cli) (built: Dec 9 2015 16:07:56) ( NTS )
In PHP7 a static array containing possible matches for the readline
completion that is returned gets corrupted on the second <TAB>.
If this static array of possible matches contains a string with a length
of >= 16, it is changed to "Closure::__invoke".
Other values in the array might simply disappear. (See Test Script
Results)
Works fine with PHP5 (5.6.12-0+deb8u1), broken in PHP7.
I'm not an expert in gdb or debugging of C programs, so please forgive
me for not adding a gdb backtrace.
Test script:
---------------
<?php
error_reporting(E_ALL);
readline_completion_function(function() {
static $possible_matches = array(
'sixteencharacter', // 16 characters or a longer string
'1',
'2',
'3',
'4',
'5',
);
var_dump($possible_matches);
return $possible_matches;
});
readline();
Expected result:
----------------
array(6) {
[0] =>
string(16) "sixteencharacter"
[1] =>
string(1) "1"
[2] =>
string(1) "2"
[3] =>
string(1) "3"
[4] =>
string(1) "4"
[5] =>
string(1) "5"
}
array(6) {
[0] =>
string(16) "sixteencharacter"
[1] =>
string(1) "1"
[2] =>
string(1) "2"
[3] =>
string(1) "3"
[4] =>
string(1) "4"
[5] =>
string(1) "5"
}
1 2 3 4 5
sixteencharacter
Actual result:
--------------
array(6) {
[0]=>
string(16) "sixteencharacter"
[1]=>
string(1) "1"
[2]=>
string(1) "2"
[3]=>
string(1) "3"
[4]=>
string(1) "4"
[5]=>
string(1) "5"
}
array(6) {
[0]=>
string(17) "Closure::__invoke"
[1]=>
string(1) "1"
[2]=>
string(1) "2"
[3]=>
string(1) "3"
[4]=>
string(1) "4"
[5]=>
string(0) ""
}
1 2 3
4 Closure::__invoke
--
Edit bug report at https://bugs.php.net/bug.php?id=71094&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71094&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71094&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71094&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71094&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71094&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71094&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71094&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71094&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71094&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71094&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71094&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71094&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71094&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71094&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71094&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71094&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71094&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71094&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71094&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71094&r=mysqlcfg