[PATCH] display mask on enter to sigreturn, not exit

Jamie Lokier jamie at shareable.org
Wed Jan 11 00:27:56 UTC 2012


Denys Vlasenko wrote:
> On 01/10/2012 09:19 PM, Dmitry V. Levin wrote:
> >> While at it, I made it so that we do display returned value/errno.
> >> I see no point in hiding it and showing uninformative "= ?" instead.
> >
> > Is there any actual difference?  Is there any case when sigreturn() may
> > "return" something different from EINTR?
> 
> Yes. -EINTR return means that the interrupted system call won't be restarted.
> It looks like this:
> 
> rt_sigsuspend([ABRT])                   = ? ERESTARTNOHAND (To be restarted)
> --- {si_signo=SIGALRM, si_code=SI_KERNEL, si_value={int=134513920, ptr=0x8048500}} (Alarm clock) ---
> alarm(1)                                = 0
> sigreturn() (mask now [ABRT])           = -1 EINTR (Interrupted system call)
> 
> Whereas the case when syscall is restarted looks like this:
> 
> read(0, 0x8121750, 1024)                = ? ERESTARTSYS (To be restarted)
> --- {si_signo=SIGALRM, si_code=SI_KERNEL, si_value={int=134513920, ptr=0x8048500}} (Alarm clock) ---
> alarm(1)                                = 0
> sigreturn() (mask now [ABRT])           = 3
> read(0, 0x8121750, 1024)...
> 
> This is a potentially useful bit of information we weren't showing.

You are showing it earlier as ERESTARTNOHAND vs. ERESTARTSYS.

It might be nice if EINTR showed up somewhere though, as that's what
userspace sees.  Maybe just convert ERESTARTNOHAND to "= -1 EINTR",
and ERESTARTSYS to "= ? (To be restarted)"?

I don't think you can treat sigreturn() as a syscall return value at
all, depending on what it is returning to.  E.g. it could show EINTR
or some other errno, but in fact just be the interrupted's value of
EAX (on x86-32) in a loop, and is no more meaningful than any other
register.

You can't recognise the difference by tracking a stack of signal
entries and exits, because sigreturn() can jump to a different place
in programs using sigsetjmp/siglongjmp and things like that. So a
synchronous signal can return to asynchronous context and vice versa.
Unusual but allowed.  E.g. I think GNU Pth will sometimes look that way.

All the best,
-- Jamie




More information about the Strace-devel mailing list