SIGALRM and default handler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SIGALRM and default handler

Holger Freyther
Dear Paolo,

I am running an image with gst-remote and it appears to be terminated
with SIGALRM due having a default handler. I thought it might have
been introduced by looking with GDB but it happens with strace (sure
both gdb and strace use ptrace).


The last seconds of the process:

clock_gettime(CLOCK_MONOTONIC, {43555416, 935715871}) = 0
rt_sigaction(SIGALRM, {0xb7699d50, ~[QUIT ILL ABRT BUS SEGV RTMIN RT_1], 0}, {SIG_DFL, ~[QUIT ILL ABRT BUS KILL SEGV STOP RTMIN RT_1], 0}, 8) = 0
timer_settime(0x2, TIMER_ABSTIME, {it_interval={0, 0}, it_value={43555426, 935132484}}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC, {43555416, 935873546}) = 0
clock_gettime(CLOCK_MONOTONIC, {43555416, 935909305}) = 0
clock_gettime(CLOCK_MONOTONIC, {43555416, 935934943}) = 0
rt_sigaction(SIGALRM, {0xb7699d50, ~[QUIT ILL ABRT BUS SEGV RTMIN RT_1], 0}, {0xb7699d50, ~[QUIT ILL ABRT BUS KILL SEGV STOP RTMIN RT_1], 0}, 8) = 0
timer_settime(0x2, TIMER_ABSTIME, {it_interval={0, 0}, it_value={43555426, 935132484}}, NULL) = 0
rt_sigprocmask(SIG_BLOCK, ~[QUIT ILL ABRT BUS SEGV RTMIN RT_1], [], 8) = 0
rt_sigsuspend([])                       = ? ERESTARTNOHAND (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
rt_sigaction(SIGALRM, {SIG_DFL, ~[QUIT ILL ABRT BUS SEGV RTMIN RT_1], 0}, {0xb7699d50, ~[QUIT ILL ABRT BUS KILL SEGV STOP RTMIN RT_1], 0}, 8) = 0
sigreturn()                             = ? (mask now ~[QUIT ILL ABRT BUS KILL SEGV STOP RTMIN])
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
clock_gettime(CLOCK_MONOTONIC, {43555426, 935432004}) = 0
clock_gettime(CLOCK_MONOTONIC, {43555426, 935478859}) = 0
clock_gettime(CLOCK_MONOTONIC, {43555426, 935506023}) = 0
rt_sigaction(SIGALRM, {0xb7699d50, ~[QUIT ILL ABRT BUS SEGV RTMIN RT_1], 0}, {SIG_DFL, ~[QUIT ILL ABRT BUS KILL SEGV STOP RTMIN RT_1], 0}, 8) = 0
timer_settime(0x2, TIMER_ABSTIME, {it_interval={0, 0}, it_value={43555426, 935873546}}, NULL) = 0
poll([{fd=7, events=POLLIN}], 1, 0)     = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0)     = 0 (Timeout)
clock_gettime(CLOCK_MONOTONIC, {43555426, 935769073}) = 0
clock_gettime(CLOCK_MONOTONIC, {43555426, 935808586}) = 0
clock_gettime(CLOCK_MONOTONIC, {43555426, 935834467}) = 0
rt_sigaction(SIGALRM, {0xb7699d50, ~[QUIT ILL ABRT BUS SEGV RTMIN RT_1], 0}, {0xb7699d50, ~[QUIT ILL ABRT BUS KILL SEGV STOP RTMIN RT_1], 0}, 8) = 0
--- SIGALRM (Alarm clock) @ 0 (0) ---
rt_sigaction(SIGALRM, {SIG_DFL, ~[QUIT ILL ABRT BUS SEGV RTMIN RT_1], 0}, {0xb7699d50, ~[QUIT ILL ABRT BUS KILL SEGV STOP RTMIN RT_1], 0}, 8) = 0
sigreturn()                             = ? (mask now [])
timer_settime(0x2, TIMER_ABSTIME, {it_interval={0, 0}, it_value={43555426, 935873546}}, NULL) = 0
--- SIGALRM (Alarm clock) @ 0 (0) ---
Process 4880 detached


So...

1.) We set rt_sigaction with SIGALRM and provide an address..
2.) We get the signal and set SIGALRM and something is setting
it back to the default handler and we receive a second SIGALRM.

So....

either we don't handle the "bottom-half" quick enough or the
kernel is sending us a SIGALRM too early.

In any case whoever sets rt_sigaction to default is probably
wrong ind oing that?



#0  *__GI___sigaction (sig=14, act=0xbfe20de4, oact=0xbfe20d58) at ../nptl/sigaction.c:37
#1  0xb768539a in _gst_set_signal_handler (signum=14, handlerFunc=0)
    at sysdep/posix/signals.c:130
#2  0xb76b2daf in signal_handler (sig=14) at events.c:82
#3  <signal handler called>
#4  0xb76ff424 in __kernel_vsyscall ()
#5  0xb74f5b57 in do_sigsuspend (set=0xb760dff4)
    at ../sysdeps/unix/sysv/linux/sigsuspend.c:63


So when handlerFunc=0 we seem to revert SIG_DEF for SIGALRM?





_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: SIGALRM and default handler

Holger Freyther
On Mon, Sep 15, 2014 at 07:46:54PM +0200, Holger Hans Peter Freyther wrote:

> #0  *__GI___sigaction (sig=14, act=0xbfe20de4, oact=0xbfe20d58) at ../nptl/sigaction.c:37
> #1  0xb768539a in _gst_set_signal_handler (signum=14, handlerFunc=0)
>     at sysdep/posix/signals.c:130
> #2  0xb76b2daf in signal_handler (sig=14) at events.c:82

RETSIGTYPE
signal_handler (int sig)
{
  if (_gst_sem_int_vec[sig].data)
    {
      if (IS_CLASS (_gst_sem_int_vec[sig].data, _gst_semaphore_class))
        _gst_async_call_internal (&_gst_sem_int_vec[sig]);
      else
        {
          _gst_errorf
            ("C signal trapped, but no semaphore was waiting");
          raise (sig);
        }
    }

  _gst_set_signal_handler (sig, SIG_DFL);
  _gst_wakeup ();
}



So, should we uncondtionally set it to SIG_IGN? Or should we only
do this for signals that would lead to termination?

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: SIGALRM and default handler

Paolo Bonzini-2
In reply to this post by Holger Freyther
Il 15/09/2014 19:46, Holger Hans Peter Freyther ha scritto:

> Dear Paolo,
>
> I am running an image with gst-remote and it appears to be terminated
> with SIGALRM due having a default handler. I thought it might have
> been introduced by looking with GDB but it happens with strace (sure
> both gdb and strace use ptrace).
>
> #0  *__GI___sigaction (sig=14, act=0xbfe20de4, oact=0xbfe20d58) at ../nptl/sigaction.c:37
> #1  0xb768539a in _gst_set_signal_handler (signum=14, handlerFunc=0)
>     at sysdep/posix/signals.c:130
> #2  0xb76b2daf in signal_handler (sig=14) at events.c:82
> #3  <signal handler called>
> #4  0xb76ff424 in __kernel_vsyscall ()
> #5  0xb74f5b57 in do_sigsuspend (set=0xb760dff4)
>     at ../sysdeps/unix/sysv/linux/sigsuspend.c:63
>
>
> So when handlerFunc=0 we seem to revert SIG_DEF for SIGALRM?

Yes, I think as soon as the Smalltalk image decides to handle a signal,
the reset action should be SIG_IGN, not SIG_DFL.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk