Calling other functions while concurrently calling exit?

Martin Sebor msebor@gmail.com
Sun Sep 20 01:54:00 GMT 2015


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



More information about the Libc-alpha mailing list