From: Honggang LI <honli@redhat.com>
To: linux-rdma@vger.kernel.org
Cc: sean.hefty@intel.com
Subject: resource leak in librdmacm
Date: Tue, 21 Jan 2020 20:21:33 +0800 [thread overview]
Message-ID: <20200121122133.GA105701@dhcp-128-72.nay.redhat.com> (raw)
Hi,
We are observing resource leak issues with librdmacm. This memory leak
issue is one of those issues.
You need a working IPoIB interface to run this reproducer. This reproducer will
be killed as out of memory.
It had been compiled with "gcc -ldl -lrdmacm -g -o fd-leak.exe fd-leak.c"
Thanks
~]$ cat fd-leak.c
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <arpa/inet.h>
#include <rdma/rdma_cma.h>
#include <limits.h>
#include <sys/types.h>
#include <unistd.h>
void test(char *ipoib_ip)
{
int ret;
struct rdma_cm_id *id;
struct sockaddr_in ipoib_addr;
struct rdma_event_channel *ch;
memset(&ipoib_addr, 0, sizeof(ipoib_addr));
ipoib_addr.sin_family = AF_INET;
ipoib_addr.sin_port = 5555;
#if 0
ret = inet_pton(AF_INET, ipoib_ip, (void *)&(ipoib_addr.sin_addr));
if (ret != 1)
printf("inet_pton failed\n");
#else
ipoib_addr.sin_addr.s_addr=htonl(INADDR_ANY);
#endif
ch = rdma_create_event_channel();
if (ch == NULL)
printf("rdma_create_event_channel failed\n");
ret = rdma_create_id(ch, &id, NULL, RDMA_PS_TCP);
if (ret != 0)
printf("rdma_create_id failed\n");
ret = rdma_bind_addr(id, (struct sockaddr *) &ipoib_addr);
if (ret != 0)
printf("rdma_bind_addr failed\n");
rdma_destroy_event_channel(ch);
rdma_destroy_id(id);
}
int main(int argc, char** argv)
{
int i;
void *handle;
pid_t pid;
char path[128];
int ret;
#if 0
if (argc != 2) {
printf("usage: %s IPoIB_IP_ADDR\n", argv[0]);
exit(-1);
}
#endif
#define MAX INT_MAX
for (i = 0; i < MAX; i++) {
if (i % 1000 == 0)
printf("dlopen/dlclose test: round %d\n", i);
handle = dlopen("/usr/lib64/librdmacm.so", RTLD_NOW);
if (!handle) {
printf("dlopen failed\n");
}
test(argv[1]);
#if 1
ret = dlclose(handle);
if (ret != 0)
printf("dlclose failed\n");
#endif
}
#if 0
pid = getpid();
printf("pid = %d\n", pid);
// for(;;);
#endif
return 0;
}
next reply other threads:[~2020-01-21 12:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-21 12:21 Honggang LI [this message]
2020-01-21 15:57 ` resource leak in librdmacm 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
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=20200121122133.GA105701@dhcp-128-72.nay.redhat.com \
--to=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).