public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Florian Weimer <fweimer@redhat.com>,
	 Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [patch] libstdc++/67747 Allocate space for dirent::d_name
Date: Fri, 02 Oct 2015 17:38:00 -0000	[thread overview]
Message-ID: <560EC0F3.3020705@gmail.com> (raw)
In-Reply-To: <560EBA49.7050008@redhat.com>

On 10/02/2015 11:09 AM, Florian Weimer wrote:
> 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.

POSIX is clear: The readdir() function need not be thread-safe.
There's nothing wrong with relying on a function's thread safety
when it's documented to be thread safe by the implementation,
even if POSIX doesn't guarantee it. But doing so otherwise,
against both the standard and against the documentation, would
be risky to say the least.

>
>> 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

I'm not sure what you are basing this assertion on. In the man
pages I have looked at, memcpy is documented as MT-Safe. readdir
is documented as MT-Unsafe. The Unsafe definition is clear:
contains global and static data that is not protected.

For example, Solaris 11.2:
http://docs.oracle.com/cd/E36784_01/html/E36874/readdir-3c.html
http://docs.oracle.com/cd/E36784_01/html/E36874/memcpy-3c.html

Martin

  reply	other threads:[~2015-10-02 17:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29 12:00 Jonathan Wakely
2015-09-29 19:49 ` Martin Sebor
2015-09-30 12:00   ` Jonathan Wakely
2015-09-30 15:54     ` Martin Sebor
2015-10-01 17:23       ` Jonathan Wakely
2015-10-01 18:38         ` Jonathan Wakely
2015-10-01 23:43           ` Jonathan Wakely
2015-10-01 22:56   ` Martin Sebor
2015-10-02 12:16 ` Florian Weimer
2015-10-02 12:34   ` Jonathan Wakely
2015-10-02 12:41     ` Florian Weimer
2015-10-02 16:34       ` Jonathan Wakely
2015-10-02 16:57     ` Martin Sebor
2015-10-02 17:01       ` Jonathan Wakely
2015-10-02 17:09       ` Florian Weimer
2015-10-02 17:38         ` Martin Sebor [this message]
2015-10-02 17:43           ` Florian Weimer
2015-10-02 17:53             ` Martin Sebor
2015-10-02 18:03               ` Florian Weimer
2015-10-02 12:37   ` Sebastian Huber
2015-10-02 12:52     ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=560EC0F3.3020705@gmail.com \
    --to=msebor@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).