On Mon, Sep 12, 2011 at 05:28:36PM +0200, Ben Noordhuis <i...@bnoordhuis.nl> 
wrote:
> eio__scandir() leaks memory when opendir() returns NULL. It sets
> req->result == -1 but doesn't free the memory it allocates.

Hmm, cannot reproduce this here, do you have a testcase that shows this
behaviour?

> Attached are two patches (different takes, same solution) that fix

Neither of these patches seem to actually do anything (they just free the
data earlier) - both ptr1 and ptr2 get freed in eio_destroy, which is
called after the user callback returns. If your patches fix a memleak,
then there must be a bug somewhere else.

> 1. doesn't set req->errorno when opendir() fails (both patches fix that), and

There is actually no possible codepath in libeio that doesn't set errorno
(it's set at the end of eio_execute), and it is certainly set when I just
tried to open a nonexistand path. Do you have a testcase that shows this?

> 2. uses readdir(), which is not guaranteed to be thread-safe. glibc

libeio doesn't rely on it being threadsafe - it never calls readdir from
multiple threads on the same dirstream.

a lock inside readdir doesn't make it threadsafe, btw., as readdir can
return a pointer to a per-dirstream structure that changes between calls.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schm...@schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to