Skip to contentSkip to conversation

Memory leak in mountd

PATCH In review Steinar H. Gunderson 2 participants 2 messages May 11, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Memory leak in mountd

Hi,

A user complained that mountd was slowly eating up all available memory with about a mount per second. We tracked it down, and ended up with the following patch:

In client_compose(), free() the hostent structure returned before exiting. Normally, gethostbyaddr() returns a pointer to a static struct, but this hostent comes from either get_reliable_hostbyaddr() or get_hostent(), both which return a pointer they privately xmalloc()ed, which thus can and should be free()d.

  --- nfs-utils-1.1.0.orig/support/export/client.c
  +++ nfs-utils-1.1.0/support/export/client.c
  @@ -262,6 +262,7 @@ client_compose(struct in_addr addr)
                          name = add_name(name, clp->m_hostname);
                  }
          }
  +       free(he);
          return name;
   }

The patch was against 1.0.10 (Debian stable), but should be equivalently applied for 1.1.0. (Also, we backported the add_name() leak fix.) In addition, there's a leak in innetgr() (in glibc) that hits mountd quite hard when using netgroups, but it appears to already be fixed in at least Red Hat, and I guess this is the wrong place to complain about glibc issues :-)

/* Steinar */

Signature · 10 lines
Homepage: http://www.sesse.net/

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
#1 lore raw
Quoted 5 lines · On Friday May 11, [email protected] wrote:

Hi,

A user complained that mountd was slowly eating up all available memory with about a mount per second. We tracked it down, and ended up with the following patch:

Bother - I should have delayed 1.1.0 one more day.... but such is life.

Thanks. I've applied the patch.

Quoted 5 lines

The patch was against 1.0.10 (Debian stable), but should be equivalently applied for 1.1.0. (Also, we backported the add_name() leak fix.) In addition, there's a leak in innetgr() (in glibc) that hits mountd quite hard when using netgroups, but it appears to already be fixed in at least Red Hat, and I guess this is the wrong place to complain about glibc issues :-)

I guess, but it is good to know it nonetheless.

NeilBrown

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs