Bug 5083 - memory leak (on Solaris)
Summary: memory leak (on Solaris)
Status: CLOSED FIXED
Alias: None
Product: Samba 3.2
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 3.2.0
Hardware: Sparc Solaris
: P3 normal
Target Milestone: ---
Assignee: Michael Adam
QA Contact: Samba QA Contact
URL:
Keywords:
: 5084 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-11-15 03:07 UTC by Markus Zell
Modified: 2007-11-15 05:59 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Zell 2007-11-15 03:07:25 UTC
Hello,

while investigating a larger memory problem with samba using libumem on Solaris 10 i got the following output from libumem:

> ::umausers
112000 bytes for 1000 allocations with data size 112:
         libumem.so.1`umem_cache_alloc+0x210
         libumem.so.1`umem_alloc+0x60
         libumem.so.1`malloc+0x28
         libumem.so.1`realloc+0x7c
         Realloc+0x24
         solaris_acl_to_smb_acl+0xac
         solarisacl_sys_acl_get_fd+0x58
         fchmod_acl+0x14
         open_file_ntcreate+0x1304
         reply_ntcreate_and_X+0x1068
         switch_message+0x4c0
         smbd_process+0x7cc
         main+0xa00
         _start+0x5c

It seems, that the function solaris_acl_to_smb_acl is allocating memory which is never released, or do i miss someting?


branches/SAMBA_3_2/source/modules/vfs_solarisacl.c?rev=23784

/*
 * get the access ACL of a file referred to by a fd
 */
SMB_ACL_T solarisacl_sys_acl_get_fd(vfs_handle_struct *handle,
				    files_struct *fsp,
				    int fd)
{
	SMB_ACL_T result = NULL;
	int count;
	SOLARIS_ACL_T solaris_acl = NULL;

	DEBUG(10, ("entering solarisacl_sys_acl_get_fd.\n"));

	if (!solaris_acl_get_fd(fd, &solaris_acl, &count)) {
		goto done;
	}
	/* 
	 * The facl call returns both ACCESS and DEFAULT acls (as present). 
	 * The posix acl_get_fd function returns only the
	 * access acl. So we need to filter this out here.  
	 */
	result = solaris_acl_to_smb_acl(solaris_acl, count,
					SMB_ACL_TYPE_ACCESS);
	if (result == NULL) {
		DEBUG(10, ("conversion solaris_acl -> smb_acl failed (%s).\n",
			   strerror(errno)));
	}
	
 done:
	DEBUG(10, ("solarisacl_sys_acl_get_fd %s.\n", 
		   ((result == NULL) ? "failed" : "succeeded")));
	SAFE_FREE(solaris_acl);

###########
	return NULL;   #### <-- leak
############

}
Comment 1 Michael Adam 2007-11-15 04:02:33 UTC
*** Bug 5084 has been marked as a duplicate of this bug. ***
Comment 2 Michael Adam 2007-11-15 04:23:47 UTC
Hi Markus,

thanks for reporting this.

This is not only a memleak but also a valid result isnt returned when there was one. That last line should read "return result;" instead "return NULL;"

This is fixed in branch v3-2-test with:
http://gitweb.samba.org/?p=samba.git;a=commit;h=242fc0099cc81877d8e9630b46dfb8d4a3265d94

This also applies to samba 3.0.X : Fixed in branch v3-0-test with:
http://gitweb.samba.org/?p=samba.git;a=commit;h=1cdf89a02af6e7a2deed3f59519af97c10dbdaa3

Markus: could you please verify that this solves the issue?

Thanks, Michael
Comment 3 Markus Zell 2007-11-15 05:44:19 UTC
This problem is solved.

Thanks, Markus
Comment 4 Michael Adam 2007-11-15 05:53:11 UTC
Markus, thanks for the feedback.