On Tue, Jan 28, 2020 at 09:04:49PM -0400, Jason Gunthorpe wrote: > 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. Thanks for the explanation!