Winbindd Memory Leak

Esh, Andrew AEsh at tricord.com
Wed Oct 3 15:24:18 GMT 2001


I reported a bad memory leak in winbindd some time in the recent past. I've
made some progress finding it, so I thought I'd report. To catch up: I took
a snapshot of SAMBA_2_2 from your CVS at date "2001-10-01 1600GMT", compiled
it for winbindd, and found that it leaks memory when processing user lists.

I ran a tool called "YAMD" (Yet Another Memory Debugger) on winbindd as
winbindd was being requested to return a list of users. It doesn't matter if
"getent passwd" is used, or if "wbinfo -u" is used, both cause winbindd to
leak. BTW: YAMD can be had fairly quickly via a Google search, which yields:

	http://www3.hmc.edu/~neldredge/yamd/

This tool (once I fixed it so it could parse its own output and add symbols)
shows me a long list of identical memory leak reports (ignoring allocations
cause by database loads, loadparms, getopts and codepage loads). They
-=*ALL*=- look like this:

WARNING: Memory leak
Address 0x416bbff4, size 12
Allocated by malloc at
	??:0(??) - /lib/i686/libc.so.6(malloc+0x2d) 0x400d009d 
	/usr/local/src/samba/source/lib/talloc.c:63(talloc) -
/usr/local/samba/sbin/winbindd(strcpy+0x2b521) 0x8076651 
	/usr/local/src/samba/source/rpc_parse/parse_prs.c:133(prs_alloc_mem)
- /usr/local/samba/sbin/winbindd(strcpy+0x3ecaf) 0x8089ddf 
	/usr/local/src/samba/source/rpc_parse/parse_prs.c:841(prs_unistr2) -
/usr/local/samba/sbin/winbindd(strcpy+0x3ff4b) 0x808b07b 
	
/usr/local/src/samba/source/rpc_parse/parse_misc.c:987(smb_io_unistr2) -
/usr/local/samba/sbin/winbindd(strcpy+0x42974) 0x808daa4 
	
/usr/local/src/samba/source/rpc_parse/parse_samr.c:858(sam_io_sam_str1) -
/usr/local/samba/sbin/winbindd(strcpy+0x549d5) 0x809fb05 
	
/usr/local/src/samba/source/rpc_parse/parse_samr.c:1487(sam_io_sam_dispinfo_
1) - /usr/local/samba/sbin/winbindd(strcpy+0x55bf7) 0x80a0d27 
	
/usr/local/src/samba/source/rpc_parse/parse_samr.c:1984(samr_io_r_query_disp
info) - /usr/local/samba/sbin/winbindd(strcpy+0x56cff) 0x80a1e2f 
	
/usr/local/src/samba/source/libsmb/cli_samr.c:775(cli_samr_query_dispinfo) -
/usr/local/samba/sbin/winbindd(strcpy+0x455c5) 0x80906f5 
	
/usr/local/src/samba/source/nsswitch/winbindd_glue.c:448(wb_samr_query_dispi
nfo) - /usr/local/samba/sbin/winbindd(strcpy+0x4ab66) 0x8095c96 
	
/usr/local/src/samba/source/nsswitch/winbindd_util.c:879(winbindd_query_disp
info) - /usr/local/samba/sbin/winbindd(strcpy+0x5966) 0x8050a96 
	
/usr/local/src/samba/source/nsswitch/winbindd_user.c:413(get_sam_user_entrie
s) - /usr/local/samba/sbin/winbindd(strcpy+0x1a84) 0x804cbb4 
	
/usr/local/src/samba/source/nsswitch/winbindd_user.c:545(winbindd_getpwent)
- /usr/local/samba/sbin/winbindd(strcpy+0x1de5) 0x804cf15 
	/usr/local/src/samba/source/nsswitch/winbindd.c:295(process_request)
- /usr/local/samba/sbin/winbindd(strcpy+0x717) 0x804b847 
	/usr/local/src/samba/source/nsswitch/winbindd.c:386(process_packet)
- /usr/local/samba/sbin/winbindd(strcpy+0x8e2) 0x804ba12 
	/usr/local/src/samba/source/nsswitch/winbindd.c:623(process_loop) -
/usr/local/samba/sbin/winbindd(strcpy+0xcf4) 0x804be24 
	/usr/local/src/samba/source/nsswitch/winbindd.c:766(main) -
/usr/local/samba/sbin/winbindd(strcpy+0x1041) 0x804c171 
	??:0(??) - /lib/i686/libc.so.6(__libc_start_main+0x93) 0x4006d177 
	??:0(_start) - /usr/local/samba/sbin/winbindd(strcpy+0x31) 0x804b161


The size of the leak varies from 8 to 12 bytes, but the stack is always
identical. The call to talloc implies that all of this leaked memory could
be freed at one point by calling talloc_destroy. My problem is, I don't know
(yet) where to do that. The obvious place is somewhere in the stack listed
above, but I don't quite see where yet.

If someone had a light bulb come on over their head as they read this, then
tell me where to call talloc_destroy, or suggest some other fix to me. I can
test it and make a patch to submit. Barring that, I will continue to make
(slow) progress on this.

---
Andrew C. Esh                mail:Andrew.Esh at tricord.com
Tricord Systems, Inc.
2905 Northwest Blvd., Suite 20        763-557-9005 (main)
Plymouth, MN 55441-2644 USA      763-551-6418 (direct)
http://www.tricord.com - Tricord Home Page

-------------- next part --------------
HTML attachment scrubbed and removed


More information about the samba-technical mailing list