Skip Menu |

This queue is for tickets about the Net-SSH2 CPAN distribution.

Report information
The Basics
Id: 27368
Status: resolved
Priority: 0/
Queue: Net-SSH2

People
Owner: Nobody in particular
Requestors: kvs [...] binarysolutions.dk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Memory leak in Net:SSH2::poll()
Date: Fri, 01 Jun 2007 15:20:05 +0200
To: bug-Net-SSH2 [...] rt.cpan.org
From: Kenneth Vestergaard Schmidt <kvs [...] binarysolutions.dk>
Hi. Net:SSH2 v0.10 seems to be leaking some memory on each call to poll(). I haven't been able to determine if it's in the .pm, the .xs or the .so. I've put a script which demonstrates the bug at http://dev.binsol.dk/~kvs/net-ssh2-leak.pl I've tried reinitialising @poll on each run through the main-loop, and I've tried not using $chan->eof, so that shouldn't be it. I've disabled reading the data on the channel, since this'll make the memory-leak that much more apparent - it just gobbles up RAM. This is on an amd64 FreeBSD 6.2-system, with perl 5.8.8 and libssh2-0.14. Let me know if I missed anything, or can do/test something. -- Best Regards Kenneth Schmidt
From: sullivan [...] bear.com
The SSH2.xs function net_ss__poll() does a Perl_malloc() of pollfd but never frees it before returning. I believe the bottom of the routine should look like: if (changed < 0) { Perl_mfree( pollfd ); XSRETURN_EMPTY; } for (i = 0; i < count; ++i) { HV* hv = (HV*)SvRV(*av_fetch(event, i, 0/*lval*/)); hv_store(hv, "revents", 7, newSViv(pollfd[i].revents), 0/ *hash*/); debug("- [%d] revents %d\n", i, pollfd[i].revents); } Perl_mfree( pollfd ); XSRETURN_IV(changed);
Fixed in 0.18 based on djmsullivan's patch.