|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47949 Return value of a registered completion function is not tested
Submitted: 2009-04-11 12:14 UTC Modified: 2009-04-13 18:08 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rannou dot sebastien at gmail dot com Assigned:
Status: Not a bug Package: Readline related
PHP Version: 5.2.4 OS: GNU/Linux
Private report: No CVE-ID: None
 [2009-04-11 12:14 UTC] rannou dot sebastien at gmail dot com
If the registered function from readline_completion_function returns an empty array, a segmentation fault happens when trying to tab.

Reproduce code:

// script.php

function  foo()
    return array();


while (42)
   echo readline('> ');


Expected result:
Doing nothing or printing a new prompt.

Actual result:
$> php script.php
Segmentation fault


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-11 17:14 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read for *NIX and for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

I can't reproduce it using libreadline 5.2-4.
 [2009-04-11 18:04 UTC] rannou dot sebastien at gmail dot com
Sorry for my mistake, I thought it was with php-5.2.9, but it seems only to happen on 5.2.4.

$ php -v
PHP 5.2.4-2ubuntu5.5 with Suhosin-Patch (cli) (built: Feb 11 2009 20:09:52)

Here's the gdb trace:

Core was generated by `php segfault.php'.
Program terminated with signal 11, Segmentation fault.
[New process 18508]
#0  0xb7f5214a in ?? () from /usr/lib/
#1  0xb79e3cca in ?? () from /lib/tls/i686/cmov/
#2  0xb79e46b7 in qsort () from /lib/tls/i686/cmov/
#3  0xb7f51c3f in fn_display_match_list () from /usr/lib/
#4  0xb7f5201b in fn_complete () from /usr/lib/
#5  0xb7f577ce in rl_complete () from /usr/lib/
#6  0xb7f577f9 in ?? () from /usr/lib/
#7  0xb7f4cd36 in el_gets () from /usr/lib/
#8  0xb7f58dc5 in readline () from /usr/lib/
#9  0x08353d57 in zif_readline ()
#10 0x082f4c0b in ?? ()
#11 0x082e5648 in execute ()
#12 0x082c4443 in zend_execute_scripts ()
#13 0x0827a2b0 in php_execute_script ()
#14 0x08356a0a in main ()

I've very sorry once again. I re-open the ticket in case it interests you.

Thanks for your attention :-)
 [2009-04-13 18:08 UTC]
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 00:01:32 2024 UTC