This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Calling other functions while concurrently calling exit?
- From: Martin Sebor <msebor at gmail dot com>
- To: Carlos O'Donell <carlos at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>, Torvald Riegel <triegel at redhat dot com>, Rich Felker <dalias at aerifal dot cx>
- Date: Sat, 19 Sep 2015 19:54:47 -0600
- Subject: Re: Calling other functions while concurrently calling exit?
- Authentication-results: sourceware.org; auth=none
- References: <55FCD13B dot 8030000 at redhat dot com>
On 09/18/2015 09:06 PM, Carlos O'Donell wrote:
Is it spelled out anywhere in POSIX or ISO C that calling
other functions concurrently with exit is going to result
in undefined behaviour?
7.1.4 Use of library functions of C11 requires library functions
to avoid data races. So a program can safely call exit in one
thread and whatever other standard C function other than exit
or quick_exit in another thread.
It's obvious this is dangerous. There is global state being
shtudown and freed while threads are trying to use that
global state. However, I can't find anything that explicitly
forbids this.
Is it simply that one must read "Consequences of Process
Termination" and imply that problems might be caused by this?
It isn't entirely obvious that you can't have a thread call
dlclose while main calls exit.
I believe that's allowed by POSIX.
Martin