Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 23 Feb 2021 17:01:03 -0800
From: "Joshua M. Clulow" <>
Subject: Re: Lifetime of object returned by readdir

On Tue, 23 Feb 2021 at 09:16, Rich Felker <> wrote:
> This leaves "part of the storage associated with the DIR stream
> object" as the only reasonable place for the dirent to live, and of
> course that's the natural (for zerocopy) place for it to live anyway,
> and where it does live in existing implementations (at least glibc and
> musl).

This is also true for illumos.  We return, from readdir(3C), pointers
to the buffer in the DIR object:

And we free it all (the DIR and the buffer) at closedir(3C):

> I'd like to push to have this fixed (adding closedir as a condition
> that ends the lifetime) as part of making readdir thread-safe, but
> before opening a new Austin Group issue or following up on the
> existing one there I'd like to make sure we're on the same page.

That makes sense to me, and would match our implementation.  Our
manual pages don't currently explicitly call this behaviour out, but
it really seems like they should so I've filed a bug:


Joshua M. Clulow

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.