This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ctermid: return string literal, document MT-Safety pitfall


On 11/14/2014 05:45 PM, Alexandre Oliva wrote:

Say, given:

char foo[5] = "12";

int main() {
   signal (SIGUSR1, checkme)
   strcpy (&foo[1], "23");
}

what standard-compliant values can checkme legitimately expect to find
in foo[0], foo[1], foo[2], foo[3], and foo[4]?

foo is not an atomic object, so this is undefined.

As a tried to explain, things turn out rather messy if you add the _Atomic qualifier. I still think the values are unspecified (despite the standard saying they are not) because the accesses from strcpy and the signal handler are not sequenced.

--
Florian Weimer / Red Hat Product Security


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]