This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients amaury.forgeotdarc, ned.deily, neologix, thouis
Date 2011-12-01.22:31:20
SpamBayes Score 3.217798e-07
Marked as misclassified No
Message-id <1322778681.37.0.665053889117.issue13517@psf.upfronthosting.co.za>
In-reply-to
Content
> Is there any reason to believe that the problem is confined to OS X?

It's a bit of a grey area.
Here's what POSIX says:

http://pubs.opengroup.org/onlinepubs/009695399/functions/readdir.html

"""
The pointer returned by readdir() points to data which may be overwritten by another call to readdir() on the same directory stream. This data is not overwritten by another call to readdir() on a different directory stream.
"""

So it seems safe as long as the threads are using distinct DIR *.
However, the documentation also says this:
"""
The readdir() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe.
"""

So in theory, readddir() could use some static/global state which may make it not thread-safe.

I just had a look at glibc's implementation, and it is indeed safe:
http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/readdir.c;h=13e5e9a0213fcf37d5f289483439bff701a9708a;hb=HEAD

Every "sane" implementation should be safe in practice.

Now, it wouldn't be the first time we encounter such a stupid bug on OS X, but it would be nice to have a a short reproducer code in C to make sure.

> It's also possible that readdir() is not reentrant with lstat()

This doesn't make much sense to me.
History
Date User Action Args
2011-12-01 22:31:21neologixsetrecipients: + neologix, amaury.forgeotdarc, ned.deily, thouis
2011-12-01 22:31:21neologixsetmessageid: <1322778681.37.0.665053889117.issue13517@psf.upfronthosting.co.za>
2011-12-01 22:31:20neologixlinkissue13517 messages
2011-12-01 22:31:20neologixcreate