linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* resource leak in librdmacm
@ 2020-01-21 12:21 Honggang LI
  2020-01-21 15:57 ` Hefty, Sean
  0 siblings, 1 reply; 7+ messages in thread
From: Honggang LI @ 2020-01-21 12:21 UTC (permalink / raw)
  To: linux-rdma; +Cc: sean.hefty

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;
}
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-31  3:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2020-01-31  3:04           ` Honggang LI

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).