Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Mon, 4 Jul 2016 23:14:02 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: abort() PID 1

On Mon, Jul 04, 2016 at 03:30:23PM +0200, Igmar Palsenberg wrote:
> 
> 
> > > - the kernel will not deliver any signal to process 1, unless a signal
> > > handler for that particular signal has been installed
> > > 
> > 
> > not all signals behave that way.
> 
> For pid 1 this is the case. Unless some signals are exempt from this. 
> 
>  
> > > -if process 1 calls abort() (regardless of what purpose that would fill), then:
> > > 
> > >     - if a handler was setup, it should be done whatever the handler does
> > > 
> > >     - if a handler was not setup, nothing should happen (as in:
> > > process didn't receive any signal at all)
> > > 
> > 
> > this is raise(SIGABRT), abort is different.
> 
> Different how ? The manual says it's just a signal unblock followed by a 
> kill(self, SIGABRT).

The man page is likely wrong. Read the actual specification. It's
specified to raise SIGABRT as if by raise, but also to cause the
program to terminate with abnormal status in cases where raising the
signal does not cause termination already. And it's explicitly
forbidden from returning, ever.

> > > What the standards say:
> > > 
> > > (http://pubs.opengroup.org/onlinepubs/9699919799/)
> > > 
> > > "The SIGABRT signal shall be sent to the calling process as if by
> > > means of raise() with the argument SIGABRT."
> > > 
> > 
> > it also says
> > 
> >  "The abort() function shall cause abnormal process termination
> >   to occur, unless the signal SIGABRT is being caught and the
> >   signal handler does not return."
> > 
> > and
> > 
> >  "The abort() function shall not return."
> > 
> > (in c11 abort is _Noreturn and returning from such a function
> > is undefined behaviour).
> 
> Hmm.. What happens if a hander is installed, but that never returns ? (but 
> also doesn't terminate the process). If I read the manpage correct, it 
> says it's OK, but also says it isn't.

If the handler never returns then the program does not terminate from
the abort call. This could happen if the signal handler is exited
using longjmp/siglongjmp, or just by remaining in the signal-handling
context indefinitely, or by performing some other action to terminate
the process as part of the signal handler (e.g. _Exit).

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.