This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: ctermid: return string literal, document MT-Safety pitfall
- From: Florian Weimer <fweimer at redhat dot com>
- To: Torvald Riegel <triegel at redhat dot com>
- Cc: Alexandre Oliva <aoliva at redhat dot com>, libc-alpha at sourceware dot org
- Date: Fri, 14 Nov 2014 14:47:47 +0100
- Subject: Re: ctermid: return string literal, document MT-Safety pitfall
- Authentication-results: sourceware.org; auth=none
- References: <ortx2b8l2k dot fsf at free dot home> <54620F80 dot 3030001 at redhat dot com> <ortx22ak52 dot fsf at free dot home> <5465EF19 dot 5040802 at redhat dot com> <1415971681 dot 4535 dot 326 dot camel at triegel dot csb>
On 11/14/2014 02:28 PM, Torvald Riegel wrote:
However, the standard still required that lock-free atomic objects have
values which are not unspecified. But as far as I can tell, the
standard does not explicitly sequence operations on atomic objects,
What do you mean by "to sequence"? The sequenced-before relation can
include atomic operations, and atomic operations will be part of
happens-before.
Unlike volatile accesses, access to atomic objects do not contribute to
the sequenced-before relation directly, only their corresponding full
expressions do.
Wanting anything else would require specifying the
actual implementation, which the standard doesn't do; it might be easy
to assume that many implementations of a very simple function like
memset would behave in a certain way -- but this already breaks down
with more complex functions such as qsort (which intermediate states are
actually allowed? can it use the to-be-sorted array as scratch space?).
Also, making assumptions about intermediate states kills the as-if rule,
hampering compiler optimizations.
It tries to do that for memset_s, but I doubt it succeeds at this (we
touch this issue briefly before). I still think the language in the
standard allows the compiler to elide dead memset_s calls, despite the
intent.
--
Florian Weimer / Red Hat Product Security