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: "Carlos O'Donell" <carlos at redhat dot com>
- To: Martin Sebor <msebor at gmail 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: Mon, 21 Sep 2015 10:40:23 -0400
- Subject: Re: Calling other functions while concurrently calling exit?
- Authentication-results: sourceware.org; auth=none
- References: <55FCD13B dot 8030000 at redhat dot com> <55FE11E7 dot 4010005 at gmail dot com>
On 09/19/2015 09:54 PM, Martin Sebor wrote:
> 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.
I silently expected this to be the case.
Rich already has a bug for this here:
https://sourceware.org/bugzilla/show_bug.cgi?id=14697
Cheers,
Carlos.