Ungraceful telnet close causes memory leak - TCP-IP

This is a discussion on Ungraceful telnet close causes memory leak - TCP-IP ; Hello, I have a device that is running Interpeak IPNET - Dual IPv4/IPv6 Stack on OSE. Part of my stack test involves running essentially the perl script below numerous times. Notice that the last but one line of my script ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Ungraceful telnet close causes memory leak

  1. Ungraceful telnet close causes memory leak

    Hello,
    I have a device that is running Interpeak IPNET - Dual IPv4/IPv6 Stack on
    OSE. Part of my stack test involves running essentially the perl script
    below numerous times. Notice that the last but one line of my script is
    deliberately commented out. I wanted to test an ungraceful exit case.

    $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die');
    $telnet->open('10.8.118.215');
    $telnet->login($login, $password);

    # No 'exit' for the Telnet session since I am testing the UNGRACEFUL
    exit case
    # $telnet->print("exit\r\n");
    $telnet->close();

    I discovered that my device leaks memory for each of these telnet sessions
    and that it eventually resets after about 200 sessions. Debugging the
    source, I see that because I do not exit the session (see commented out
    line) it takes about 30 seconds before the server detects a "connection
    reset by peer". Then when the server kills the proxy process, the memory for
    it is somehow not released. So I have two problems: (1) how can I get the
    server to detect the lost connection immediately; (2) Why is the memory for
    the proxy processes not being released even though the processes themselves
    are eventually killed.

    Note that when I uncomment out the "$telnet->print("exit\r\n");" the closed
    connection is detected immediately (obviously it would since we did close
    it), the process is killed and the memory released properly. The puzzling
    thing is it is the same code segment that is executed in both cases. Only
    the entry points differ--INET_ERRNO as opposed to CHILD_DONE

    Could I do something with SO_KEEPALIVE or SO_LINGER here? Is my testcase
    even valid? What does the "close" do without the "exit"?

    Any answers or ideas would be very much appreciated.
    Nuertey



  2. Re: Ungraceful telnet close causes memory leak

    In article ,
    "Nuertey Odzeyem" wrote:

    > Hello,
    > I have a device that is running Interpeak IPNET - Dual IPv4/IPv6 Stack on
    > OSE. Part of my stack test involves running essentially the perl script
    > below numerous times. Notice that the last but one line of my script is
    > deliberately commented out. I wanted to test an ungraceful exit case.
    >
    > $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die');
    > $telnet->open('10.8.118.215');
    > $telnet->login($login, $password);
    >
    > # No 'exit' for the Telnet session since I am testing the UNGRACEFUL
    > exit case
    > # $telnet->print("exit\r\n");
    > $telnet->close();
    >
    > I discovered that my device leaks memory for each of these telnet sessions
    > and that it eventually resets after about 200 sessions. Debugging the
    > source, I see that because I do not exit the session (see commented out
    > line) it takes about 30 seconds before the server detects a "connection
    > reset by peer". Then when the server kills the proxy process, the memory for
    > it is somehow not released. So I have two problems: (1) how can I get the
    > server to detect the lost connection immediately; (2) Why is the memory for
    > the proxy processes not being released even though the processes themselves
    > are eventually killed.


    This is a bug in the device. Report it to the device's manufacturer,
    and maybe they'll fix it in a firmware update.

    >
    > Note that when I uncomment out the "$telnet->print("exit\r\n");" the closed
    > connection is detected immediately (obviously it would since we did close
    > it), the process is killed and the memory released properly. The puzzling
    > thing is it is the same code segment that is executed in both cases. Only
    > the entry points differ--INET_ERRNO as opposed to CHILD_DONE
    >
    > Could I do something with SO_KEEPALIVE or SO_LINGER here? Is my testcase
    > even valid? What does the "close" do without the "exit"?


    Why don't you just do the "exit"?

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  3. Re: Ungraceful telnet close causes memory leak

    On Jul 3, 1:09 pm, "Nuertey Odzeyem"
    wrote:

    > Could I do something with SO_KEEPALIVE or SO_LINGER here?


    No.

    > Is my testcase
    > even valid?


    Yes. It proves the device is broken/buggy.

    > What does the "close" do without the "exit"?


    It shuts down the TCP connection without terminating the application
    on the other side first. This is a common case and I think it's fair
    to argue that a device that mishandles it is broken.

    DS


+ Reply to Thread