php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70458 Memory leak
Submitted: 2015-09-08 08:48 UTC Modified: 2015-09-11 12:33 UTC
From: a6y at xakep dot ru Assigned: michael (profile)
Status: Closed Package: expect (PECL)
PHP Version: 5.4.45 OS: Linux 3.2.0-4-amd64 #1 S
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 - 20 = ?
Subscribe to this entry?

 
 [2015-09-08 08:48 UTC] a6y at xakep dot ru
Description:
------------
Trying to parse result from mulriline response. Php tring to allocate icredible memory size
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 18446744073709531321 bytes) in ... on line 38

Test script:
---------------
ini_set ("expect.timeout", 10);
ini_set ("expect.loguser", "Off");

$stream = expect_popen("ssh user@host");

while (true) {
    switch (expect_expectl ($stream, array (
        array ("password:", PASSWORD), // SSH is asking for password
        array ("yes/no)?", YESNO), // SSH is asking whether to store the host entry
        array ("~$ ", SHELL, EXP_EXACT), // We've got the shell!
    ))) {
        case PASSWORD:
            fwrite ($stream, "pwd\n");
            break;

        case YESNO:
            fwrite ($stream, "yes\n");
            break;

        case SHELL:
            fwrite ($stream, "uname -a\n");
            while (true) {
                switch (expect_expectl ($stream, array (
                    array ("~$ ", SHELL, EXP_EXACT), // We've got the shell!
                    array ("^.*[^~]$", UNAME, EXP_REGEXP), // uname -a output
                ), $match)) {
                    case UNAME:
                        $uname = $match;
                        break;

                    case SHELL:
                        // Run update:
                        var_dump($uname);
                        fwrite ($stream, "ls -la\n");
                        while (true) {
                            switch (expect_expectl ($stream, array (
                                array ("~$ ", SHELL, EXP_EXACT), // We've got the shell!
                                array ("[^~]*~$", UNAME, EXP_REGEXP), // uname -a output
                            ), $match1)) {
                                case UNAME:
                                    $uname = $match1;
                                    break;

                                case SHELL:
                                    // Run update:
                                    var_dump($uname);
                                    fwrite ($stream, "exit\n");
                                    break 3;

                                case EXP_TIMEOUT:
                                case EXP_EOF:
                                    var_dump($uname);
                                    break 3;

                                default:
                                    die ("Error has occurred!\n");
                            }
                        }
                        break 2;

                    case EXP_TIMEOUT:
                    case EXP_EOF:
                        break 2;

                    default:
                        die ("Error has occurred!\n");
                }
            }
            break 2;

        case EXP_TIMEOUT:
        case EXP_EOF:
            break 2;

        default:
            die ("Error has occurred!\n");
    }
}

fclose ($stream);

Expected result:
----------------
Not leaking memory


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-11 12:29 UTC] michael@php.net
Automatic comment from SVN on behalf of michael
Revision: http://svn.php.net/viewvc/?view=revision&revision=337807
Log: Fixed #70458
 [2015-09-11 12:33 UTC] michael@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: michael
 [2015-09-11 12:33 UTC] michael@php.net
Fixed in new release (0.3.2).
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 08:01:24 2019 UTC