www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: memory leak after upgrade from 1.4.3 to 1.6.0

Re: memory leak after upgrade from 1.4.3 to 1.6.0

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Thu, 21 Jan 2016 09:52:26 +0100

On Thursday 21 January 2016 08:02:59 suyog jadhav wrote:
> Hi
>
> we have been using libssh2 library in our project for some time. (since 1.2
> release)
>
> We remotely monitor multiple remote hosts (100+), and do following.
>
> 1)open session.
> 2)execute commands periodically. (e.g. each minute run iostat,vmstat)
>
> We were using 1.4.3 version of the library until now and everything was
> working fine.
>
> Recently we have upgraded library to 1.6.0 and we are seeing memory
> growth/leak in the process. Our code has not changed in the library
> upgrade.
>
> Our valgrind analysis shows that the leak is in the "libssh2_session_init_ex
> (session.c:487)" and "libssh2_channel_open_ex (channel.c:349)".

In case your code uses the non-blocking mode of libssh2, does it properly
handle LIBSSH2_ERROR_EAGAIN coming out of libssh2_channel_free() and
libssh2_session_free()?

Kamil

> Could you please let me know if there is any change in 1.6.0 which may cause
> this leak. Is there any api behavior that has changed which needs extra
> error handling now? Also if you could point to a way/approach for solving
> this leak, it would be greatly appreciated.
>
> Valgrind trace.
>
> ==9718== 582,541 (545,440 direct, 37,101 indirect) bytes in 10 blocks are
> definitely lost in loss record 642 of 645 ==9718== at 0x4A06A2E: malloc
> (vg_replace_malloc.c:270)
> ==9718== by 0x41A830: libssh2_default_alloc (session.c:67)
> ==9718== by 0x41B1CC: libssh2_session_init_ex (session.c:487)
>
>
>
> ==9718== 10,144,824 (106,640 direct, 10,038,184 indirect) bytes in 155
> blocks are definitely lost in loss record 644 of 645 ==9718== at
> 0x4A06A2E: malloc (vg_replace_malloc.c:270)
> ==9718== by 0x41A830: libssh2_default_alloc (session.c:67)
> ==9718== by 0x4162A5: _libssh2_calloc (misc.c:625)
> ==9718== by 0x40ACFC: _libssh2_channel_open (channel.c:160)
> ==9718== by 0x40B4C4: libssh2_channel_open_ex (channel.c:349)
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2016-01-21

the libssh2 team