[lxc-devel] [PATCH] fix fd leak in test-concurrent

S.Çağlar Onur caglar at 10ur.org
Mon Mar 10 17:48:00 UTC 2014


On Mon, Mar 10, 2014 at 10:58 AM, Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
> Quoting S.Çağlar Onur (caglar at 10ur.org):
>> On Fri, Mar 7, 2014 at 5:12 PM, Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
>> > Quoting Dwight Engen (dwight.engen at oracle.com):
>> >> Opening a debug log for every thread at every iteration of test-concurrent
>> >> causes it to quickly run out of fd's because this fd is leaked. Fix this
>> >> by adding a new api: lxc_log_close().
>> >>
>> >> As Caglar noted, the log handling is in general a bit "interesting" because
>> >> a logfile can be opened through the per-container api
>> >> c->set_config_item("lxc.logfile") but lxc_log_fd is now per-thread data. It
>> >> just so happens in test-concurrent that there is a 1:1 mapping of threads
>> >> to logfiles.
>> >
>> > Will at_exit work at thread exit?
>> >
>> >> Split out getting debug logs from quiet since I think they are useful
>> >> separately. If debug is specified, get a log of any mode, not just during
>> >> start.
>> >>
>> >> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
>>
>> Looks like we are also leaking cgmanager connections, this is while
>> test-concurrent is running (it eventual run out of fds and fails)
>>
>> [caglar at oOo:~/Projects/lxc(master)] sudo ls /proc/2063/fd -al | wc -l
>> 874
>> [caglar at oOo:~/Projects/lxc(master)] sudo ls /proc/2063/fd -al | wc -l
>> 879
>> [caglar at oOo:~/Projects/lxc(master)] sudo ls /proc/2063/fd -al | wc -l
>> 889
>> [caglar at oOo:~/Projects/lxc(master)] cat /proc/net/unix | grep cgmanager | wc -l
>> 878
>> [caglar at oOo:~/Projects/lxc(master)] cat /proc/net/unix | grep cgmanager | wc -l
>> 888
>> [caglar at oOo:~/Projects/lxc(master)] cat /proc/net/unix | grep cgmanager | wc -l
>> 893
>> [caglar at oOo:~/Projects/lxc(master)]
>
> Can we handle both with pthread_cleanup_push()?

You mean registering cleanup functions within the liblxc? If so, I'm
not sure whether it's possible, as long as I know,
pthread_cleanup_pop/push cannot span into multiple functions. But if
you meant adding push/pop into concurrent.c then I guess it's doable
if we export a function to close cgmanager socket like lxc_log_close.

> (I'll try in a few hours unless I see a patch beforehand :)

I don't think I'll be able to spend some time on this so please feel
free to take a look.

> -serge

-- 
S.Çağlar Onur <caglar at 10ur.org>


More information about the lxc-devel mailing list