This is the mail archive of the
mailing list for the libstdc++ project.
Re: [patch] libstdc++/67747 Allocate space for dirent::d_name
- From: Florian Weimer <fweimer at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>, Jonathan Wakely <jwakely at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Oct 2015 19:09:29 +0200
- Subject: Re: [patch] libstdc++/67747 Allocate space for dirent::d_name
- Authentication-results: sourceware.org; auth=none
- References: <20150929113726 dot GU12094 at redhat dot com> <560E759E dot 2000005 at redhat dot com> <20151002123428 dot GP12094 at redhat dot com> <560EB776 dot 2090504 at gmail dot com>
On 10/02/2015 06:57 PM, Martin Sebor wrote:
> Readdir isn't required to be thread-safe (it may reference global
> data) so calling it in multiple threads even with a different dirp
> argument is undefined. A thread-unsafe implementation can meet the
> POSIX requirement and still access global data but without locking.
A readdir implementation which is not thread-safe when used with
different directory streams is just buggy. It may be conforming, but so
is an implementation that always fails with EOVERFLOW.
> The Solaris implementation, for example, is explicitly documented
> as thread unsafe.
MT-safety is ambiguous for functions which operate on pointer arguments.
It is not clear if it is permitted to call the function without
synchronization on overlapping objects.
memcpy has the same thread-safety level as readdir on Solaris
(operations on overlapping objects are not thread-safe, non-overlapping
objects are), and is documented to be MT-safe.