linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Honggang LI <honli@redhat.com>
Cc: "Hefty, Sean" <sean.hefty@intel.com>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Subject: Re: resource leak in librdmacm
Date: Tue, 28 Jan 2020 21:04:49 -0400	[thread overview]
Message-ID: <20200129010449.GA29820@ziepe.ca> (raw)
In-Reply-To: <20200123142135.GA171304@dhcp-128-72.nay.redhat.com>

On Thu, Jan 23, 2020 at 10:21:35PM +0800, Honggang LI wrote:
> On Wed, Jan 22, 2020 at 11:23:02PM +0800, Honggang LI wrote:
> 
> > void test_fini(void)
> > {
> 
> 
> > 	if (handle)
> > 		dlclose(handle);
>                 ^^^^^^^
> > 	handle = NULL;
> 
> In case we did not call dlclose, there will be only one file descriptor
> leak. It will reduce the file descriptor leak.
> 
> Does that imply librdamcm was designed to load once and only unload when
> process exit?

Yes.

We had some old code that attempted to clean up on dlclose/process
exit, but it turns out that whole concept is racey and broken when
threads are used.

To run valgrind testing like this the library needs to provide some
kind of 'cleanup internal data' call, which our libries don't have. 

I think it would be useful addition to both libraries.

You should also see memleaks from valgrind on exit, IIRC. Lots of
static lists don't get cleaned.

Jason

  reply	other threads:[~2020-01-29  1:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21 12:21 resource leak in librdmacm Honggang LI
2020-01-21 15:57 ` Hefty, Sean
2020-01-22  8:56   ` Honggang LI
2020-01-22 15:22     ` Honggang LI
2020-01-23 14:21       ` Honggang LI
2020-01-29  1:04         ` Jason Gunthorpe [this message]
2020-01-31  3:04           ` Honggang LI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200129010449.GA29820@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=honli@redhat.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sean.hefty@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).